View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Cell shape connect - is there one?

Robert..


I think you were posting in the wrong thread...
but never mind..

This will do.. not ultra fast but does the trick :)
returns a collection of the (Shapes and the Range it covers)
for a particular area.

Function ShapeCover(rngToSearch As Range) As Collection
Dim rngCovered As Range, sh As Shape

Set ShapeCover = New Collection
For Each sh In ActiveSheet.Shapes
Set rngCovered = Range(sh.TopLeftCell, sh.BottomRightCell)
If Not Intersect(rngToSearch, rngCovered) Is Nothing Then
ShapeCover.Add Array(sh, rngCovered), sh.Name
End If

Next

End Function

Sub foo()
Dim x As Collection
Set x = ShapeCover([B3:G100])
Stop
End Sub

--
keepITcool

| www.XLsupport.com | keepITcool chello nl | amsterdam


Robert McCurdy wrote :

Hi all.

I know you can use the shapes properties to figure out what cell it
covers, but does any one know if the reverse is possible.

Selecting a range and via code get a true/false for "Is there a shape
intersect here?" for each cell?

I believe with normal VBA there isn't, and I'm not interested in any
C++ or API calls, just what is available within VBA.


Regards
Robert McCurdy