VBA select shapes based on their positions

后端 未结 4 2334
孤城傲影
孤城傲影 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:32

    Build a ShapeRange that meets the criteria and then Select that ShapeRange

    Sub ShapePicker()
        Dim s As Shape, sr As ShapeRange
        Dim Arr() As Variant
        Set mycell = Range("A:A").Find(What:=0, After:=Range("A1"))
        rrow = mycell.Row
    
        i = 1
        For Each s In ActiveSheet.Shapes
            If s.TopLeftCell.Row = rrow Then
                ReDim Preserve Arr(1 To i)
                Arr(i) = s.Name
                i = i + 1
            End If
        Next s
    
        Set sr = ActiveSheet.Shapes.Range(Arr)
        sr.Select
    
    End Sub
    

提交回复
热议问题