我试图隐藏或移动excel中的一系列形状。
我想要复制一系列单元格作为图片,基本上如果形状没有活动'即包含文本,然后我不希望这些单元格中的形状可见。每个形状都是链接的,如果if / vlookup为true,则形状将包含文本。
以下不起作用 - 尝试使用.Right修改.Visable,即将形状移出范围 - 但它表示对象不支持此属性或方法。
Sub Macro3()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
Dim shp As Shape
Dim tr As TextRange2
Dim grp As Shape
Dim sShape As Shape
Set shp = ws.Shapes("Line Callout 1 2")
Set tr = shp.TextFrame2.TextRange
For Each ws In ThisWorkbook.Worksheets
For Each shp In ws
If shp.Name Like "Line Callout 1" And tr.Characters.Text = "" Then
sShape.Right = 300
Else
sShape.Right = 0
End If
Next shp
Next ws
End Sub
如果我指定一个命名单元格,我可以改变其可见性,但是对于超过600个形状,我想以某种方式对其进行修改。这适用于命名形状和命名范围:
Sub Macro1()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
With ws.Shapes.Range(Array("Line Callout 1 1"))
.Fill.Visible = Range("x")
.Line.Visible = Range("x")
End With
End Sub