如何根据范围select多个形状?

如果所选范围由1个单元格组成,则select图纸中的所有graphics,否则select范围内的graphics。 这是给我麻烦的“其他”部分。 我可以select一个形状,但不是范围内的所有形状…

Public Sub ShapeSelection() Dim Sh As Shape On Error Resume Next If Selection.Rows.count * Selection.Columns.count = 1 Then ActiveSheet.Shapes.SelectAll Else Application.ScreenUpdating = False With ActiveSheet For Each Sh In .Shapes If Not Application.Intersect(Sh.TopLeftCell, .Range(Selection.Address)) Is Nothing Then Sh.Select End If Next Sh End With Application.ScreenUpdating = True End If End Sub 

尝试这个。 注意包含“False”一词:

 Public Sub ShapeSelection() Dim Sh As Shape Dim selectedOne As Boolean On Error Resume Next If Selection.Rows.count * Selection.Columns.count = 1 Then ActiveSheet.Shapes.SelectAll Else Application.ScreenUpdating = False With ActiveSheet For Each Sh In .Shapes If Not Application.Intersect(Sh.TopLeftCell, .Range(Selection.Address)) Is Nothing Then If selectedOne = False Then Sh.Select selectedOne = True Else Sh.Select(False) End If End If Next Sh End With Application.ScreenUpdating = True End If End Sub