Objects above cell

  • Thread starter Thread starter Geoff
  • Start date Start date
G

Geoff

Is there a way to get the object above a cell using VBA?

Thanks in advance
 
One way is to loop through all the objects/shapes.

Option Explicit
Sub testme()
Dim myShape As Shape
Dim myRng As Range
Dim myCell As Range

With ActiveSheet
Set myCell = .Range("G12")
For Each myShape In .Shapes
Set myRng = .Range(myShape.TopLeftCell, myShape.BottomRightCell)
If Intersect(myRng, myCell) Is Nothing Then
'nope, keep looking
Else
MsgBox "Found: " & myShape.Name & " above " _
& myCell.Address(0, 0)
'keep looking or
'exit for
End If
Next myShape
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top