View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Please help Please help is offline
external usenet poster
 
Posts: 75
Default Please help with my code

Don,

First of all, thanks for the code. Secondly, I will make a note about the
meaningful subject line.

I take your code and make a few changes to suit my needs, and it does not
seem to work. Can you help me more? Below is my modified code.

In addition to removing the shapes, I also like to include the code to
message the users the # of shapes got removed and referencing the cells.

In addition, how does your code know what type of shape to delete because I
only want to delete the shapes which are 13 (msoLinkedPicture)? You also
reference the range E1:E24. Would it work if a user selects other than
E1:E24?

What do you mean by "'does the top left corner of the shape overlap
rngUsable?"?

Thanks.


Dim shpLoop As Shape
dim cCount as Integer
Set rngUsable = Range("e1:e24")
For Each shpLoop In ActiveSheet.Shapes
'does the top left corner of the shape overlap rngUsable?
If Not (Application.Intersect(rngUsable, shpLoop.TopLeftCell) Is Nothing)
Then
cCount = cCount + 1
shpLoop.Delete
End If
Next shpLoop
MsgBox "You just removed " & cCount & " check marks in highlighted cells
'" & rngUsuable.Name & "' of the Worksheet '" & ActiveSheet.Name & "'."


"Don Guillett" wrote:

Please use a MEANINGFUL subject line. I'm not sure you can select the range
if the the shape is covering it, But if so adapt this to suit.

Sub ShapesInRangeDelete() 'Iain
Dim shpLoop As Shape
Set rngUsable = Range("e1:e24")
For Each shpLoop In ActiveSheet.Shapes
'does the top left corner of the shape overlap rngUsable?
If Not (Application.Intersect(rngUsable, shpLoop.TopLeftCell) Is Nothing)
Then
shpLoop.Delete
End If
Next shpLoop
End Sub
======
This might work best. Hold down the ctrl key while selecting the shapes(not
the range)

Sub DeleteSelectedshapes()
Selection.Delete
End sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Please Help" wrote in message
...
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 & "'."