VBA select shapes based on their positions

后端 未结 4 2272
孤城傲影
孤城傲影 2021-01-07 01:05

How do I select all shapes (array? range?) where the value in Cell \"A:Shape.TopLeftCell.Row\" = 0 ? \"ente

4条回答
  •  [愿得一人]
    2021-01-07 01:28

    Just as an alternative, you can reverse the logic and select as you go, then assign the selection to a shaperange if required:

    Sub ShapePicker()
        Dim s As Shape
        Dim sr As ShapeRange
        Dim i As Long
    
        i = 1
        For Each s In ActiveSheet.Shapes
            If Cells(s.TopLeftCell.Row, "A").Value = 0 Then
                s.Select (i = 1)
                i = i + 1
            End If
        Next s
        Set sr = Selection.ShapeRange
    End Sub
    

提交回复
热议问题