利用vba代码如何选取指定区域内的所有shape对象.
展开全部
代码及注释如下:
Sub main()
Dim Sh1(1 To 100) As String‘定义数组,用于存放shape名
Dim sh As Shape
Dim i As Integer
With Worksheets("Sheet6")
For Each sh In .Shapes'遍历所有的Shape对象
If Not Application.Intersect(sh.TopLeftCell, .Range("A1:J20")) Is Nothing Then'Shape对象如何不在A1:J20区域中
i = i + 1'累加数量
Sh1(i) = sh.Name'将Shape名依次存放在数组Sh1中
End If
Next sh
End With
ActiveSheet.Shapes.Range(Sh1).Select,选中Sh1中存放的Shape
End Sub
Sub main()
Dim Sh1(1 To 100) As String‘定义数组,用于存放shape名
Dim sh As Shape
Dim i As Integer
With Worksheets("Sheet6")
For Each sh In .Shapes'遍历所有的Shape对象
If Not Application.Intersect(sh.TopLeftCell, .Range("A1:J20")) Is Nothing Then'Shape对象如何不在A1:J20区域中
i = i + 1'累加数量
Sh1(i) = sh.Name'将Shape名依次存放在数组Sh1中
End If
Next sh
End With
ActiveSheet.Shapes.Range(Sh1).Select,选中Sh1中存放的Shape
End Sub
展开全部
返回A1:D20 内SHAPE名称,名称放在A列;代码如下:
Sub aa()
Dim ms As Shape
For Each ms In Sheets("Sheet6").Shapes
If ms.BottomRightCell.Row <= 20 And ms.BottomRightCell.Column <= 10 Then
k = k + 1
Cells(k, 1) = ms.Name
End If
Next ms
End Sub
更多追问追答
追问
返回名称后,能直接将它们都选中么
追答
选中你要进行操作吗?说一下,下一步做什么呢!
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询