VBA select shapes based on their positions

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

    There is another way around of this. I came across this post while looking for a solution.

    So here it is the Answer for anyone looking for a way around.

    The Method goes like this:

    Run a loop like this once to change the names of the Rectangles to the Address of their TopLeftCell

     Dim sh As Shape
    
     For Each sh In ActiveSheet.Shapes
    
        sh.Name = sh.TopLeftCell.Address
    
     Next sh
    

    Now in any other code you can directly access the shape using:

    ActiveSheet.Shapes(ActiveCell.Address).Select
    

    This is one way you can achieve it. Though there doesn't exist a method that you are looking for.

    You can change the ActiveCell.Address any range object or maybe just the text itself. It will take values like $D$4

    Tried and Tested, it works Smoothly.

提交回复
热议问题