Please help with Count

P

Please Help

Hello all,

I have a macro to delete the shapes in an active worksheet. After the
shapes are deleted, users will receive a message that they have been deleted.
In the message, I would like to insert the number of shapes that were
deleted. Can someone help me with counting those deleted shapes?

Below is my current code:

Dim cMarks As Shape

For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then cMarks.Delete
Next cMarks
MsgBox "You have removed " & cMarks & " check marks in Worksheet '" &
ActiveSheet.Name & "'."

Thanks.
 
D

Don Guillett

try
For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then
mc=mc+1
cMarks.Delete
end if
Next cMarks
MsgBox "You have removed " & mc & " check marks in Worksheet '" &
ActiveSheet.Name & "'."
 
P

Per Jessen

Hi

Have a look at this

Dim cMarks As Shape
Dim Counter As Double
For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then
cMarks.Delete
Counter = Counter + 1
End If
Next cMarks
MsgBox "You have removed " & Counter & " check marks in Worksheet '" & _
ActiveSheet.Name & "'."

Regards

Per
 
K

Keith R

See edited (air)code below.
HTH,
Keith

Please Help said:
Hello all,

I have a macro to delete the shapes in an active worksheet. After the
shapes are deleted, users will receive a message that they have been
deleted.
In the message, I would like to insert the number of shapes that were
deleted. Can someone help me with counting those deleted shapes?

Below is my current code:

Dim cMarks As Shape
Dim cCount as Integer

cCount = 0
For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then
cMarks.Delete
cCount = cCount+1
End if
 
P

Please Help

Hi guys,

Thank you very much for your helps. The code works very well.

Can you help me one more thing?

Instead of deleting all the shapes in active sheet, can you help me with the
code to delete the shapes in the selected cells in the active sheet?

For example, if I select cells A1, B1, C5:G10 and when I run the macro, the
macro will only delete the shapes in those selected cells.

Thanks.
 

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

Top