View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Please help with my code

the problem is shapes do not sit in cell they sit ontop of cells. they also
don't have a row or column.

Both cells and shapes do have left, top, height, width which are pixel
measurments. You can write code like the sample below to compartre shapes
with cells.

Note: The code below doesn't test the right side or botttom of the shape to
see if it is inside the range. Wasn't sure if this is a requirement. The
code only tests the left side of the shape and the top of the shape.

"Please Help" wrote:

Good morning,

Please help with my code below.

Basically, my code will remove the shapes in the cells selected (instead of
all the shapes in the active worksheet) of the active worksheet, and it is
not work.

For example, if I select cells A1, B1, and C5:G10 and when I run the macro,
the macro will only remove the shapes in those cells. Please note the cells
selected will be done by users and may not be the same as referenced above.

Thanks.

Dim cMarks As Shape
Dim sCells as Range
Dim cCount as Integer

sCells.Select
For Each sCells In ActiveSheet
For Each cMarks In sCells.Shapes
If cMarks.Type = 13 Then
cCount = cCount + 1
cMarks.Delete
End If
Next cMarks
Next sCells
MsgBox "You have removed " & cCount & " check marks in highlighted cells
'" & sCells.Name & "' of the Worksheet '" &
ActiveSheet.Name & "'."