gpt4 book ai didi

vba - 不使用 SELECT 插入形状

转载 作者:行者123 更新时间:2023-12-02 09:42:58 25 4
gpt4 key购买 nike

我的一段代码会遍历一系列单元格,如果某些单元格满足某些条件 - 则将形状插入到该单元格中。它有效,但我想找到一种替代方法来避免 select

'above - code to find satisfying cell
ActWS.Activate 'Activate Sheet
ActWS.Cells(rActPlan - 1, vReturnColumn).Select 'Select satisfying cell
ActiveSheet.Shapes.AddShape(msoShapeOval, ActiveCell.Left, ActiveCell.Top, ActiveCell.Width, ActiveCell.Height).Select
Selection.ShapeRange.Fill.Visible = msoFalse
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 255, 0)
.Weight = 2.25
End With

最佳答案

此代码删除所有 .SelectActiveCell 引用:

With ActWs

Dim rng as Range
Set rng = .Cells(rActPlan - 1, vReturnColumn)

Dim shp as Shape
Set shp = .Shapes.AddShape(msoShapeOval, rng.Left, rng.Top, rng.Width, rng.Height)

With shp.ShapeRange

.Fill.Visible = msoFalse

With .Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 255, 0)
.Transparency = 0
.Weight = 2.25
End With

End With

End With

关于vba - 不使用 SELECT 插入形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34930221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com