Thanks in advance
--
Gary''s Student - gsnu200764
"Gary''s Student"
wrote in message
Function Cover(strShapeName As String, cAdd As String) As Variant
On Error GoTo ErrHandler
With Range(cAdd).Parent.Shapes(strShapeName)
Cover = Not Intersect(Range(cAdd), Range(.TopLeftCell, .BottomRightCell)) Is Nothing
End With
Exit Function
ErrHandler:
Cover = "Bad :-("
End Function
Sub TestTheFunction()
MsgBox Cover("Rectangle 1", "C4")
End Sub
--
HTH,
Bernie
MS Excel MVP
"Gary''s Student" <GarysS...@discussions.microsoft.com> wrote in message
news:1914E508-A653-4673...@microsoft.com...
HTH,
Bernie
MS Excel MVP
"Bernie Deitrick" <deitbe @ consumer dot org> wrote in message
news:ubKn3pTU...@TK2MSFTNGP06.phx.gbl...
Because the shape and cell are both rectangle you need to test all four
corners of the shape against al four sides of the cell to determine a partial
overlap
for the top left corner of the shape it would be something like this
'four corners of the shape
sxleft = shape.left
sytop = shape.top
sxright = sxleft + shape.width
sxbottom = sytop + shape.height
'four corners of the cell
cxleft = shape.left
cytop = shape.top
cxright = cxleft + shape.width
cxbottom = cytop + shape.height
if (sxleft >= cxleft) and sxleft <= cxright) and
(sxtop >= cxtop) and sxtop <= cxbottom) then
overlap is true
end if
now repeat for other three conditions of. Instead of sxleft and sxtop use
sxright and sxtop
sxleft and sxbotom
sxright and sxbotom
Only one of the 4 conditions needs to be met to determine overlap.
obj as Object to cater for any drawingobject type, eg simply Selection, or
if a Shape, but change to As Shape if you prefer.
Regards,
Peter T
"Gary''s Student" <GarysS...@discussions.microsoft.com> wrote in message
news:1914E508-A653-4673...@microsoft.com...
Regards,
Peter T
"Peter T" <peter_t@discussions> wrote in message
news:%23FQ2GzT...@TK2MSFTNGP02.phx.gbl...
If graphics obscure important cells, move the graphics to the right.
--
Gary''s Student - gsnu200764