J
Joel
Glad the problem is so simple. Just moving one line of code should fix
problem I'm also initializing the count just in case of problems. I also
made a changge so the address printed in the msgbox contains all the
addresses.
Sub test()
Dim cMarks As Shape
Dim sCells As Range
Dim cCount As Integer
cCount = 0
address_string = ""
For Each myRange In Selection.Areas
if address_string = "" then
address_string = myRange.address
else
address_string = address_string & "," & _
myRange.address
end if
myRows = myRange.Rows.Count
LastRow = myRange.Row + myRows - 1
myCols = myRange.Columns.Count
LastCol = myRange.Column + myCols - 1
Set LastCell = Cells(LastRow, LastCol)
RLeft = myRange.Left
RTop = myRange.Top
RRight = LastCell.Left + LastCell.Width
RBottom = LastCell.Top + LastCell.Width
For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then
If cMarks.Top >= RTop And _
cMarks.Top <= RBottom And _
cMarks.Left >= RLeft And _
cMarks.Left <= RRight Then
cCount = cCount + 1
cMarks.Delete
End If
End If
Next cMarks
Next myRange
MsgBox "You have removed " & cCount & _
" check marks in highlighted cells " _
& address_string & "' of the Worksheet '" & _
ActiveSheet.Name & "'."
End Sub
problem I'm also initializing the count just in case of problems. I also
made a changge so the address printed in the msgbox contains all the
addresses.
Sub test()
Dim cMarks As Shape
Dim sCells As Range
Dim cCount As Integer
cCount = 0
address_string = ""
For Each myRange In Selection.Areas
if address_string = "" then
address_string = myRange.address
else
address_string = address_string & "," & _
myRange.address
end if
myRows = myRange.Rows.Count
LastRow = myRange.Row + myRows - 1
myCols = myRange.Columns.Count
LastCol = myRange.Column + myCols - 1
Set LastCell = Cells(LastRow, LastCol)
RLeft = myRange.Left
RTop = myRange.Top
RRight = LastCell.Left + LastCell.Width
RBottom = LastCell.Top + LastCell.Width
For Each cMarks In ActiveSheet.Shapes
If cMarks.Type = 13 Then
If cMarks.Top >= RTop And _
cMarks.Top <= RBottom And _
cMarks.Left >= RLeft And _
cMarks.Left <= RRight Then
cCount = cCount + 1
cMarks.Delete
End If
End If
Next cMarks
Next myRange
MsgBox "You have removed " & cCount & _
" check marks in highlighted cells " _
& address_string & "' of the Worksheet '" & _
ActiveSheet.Name & "'."
End Sub