Hi all,
I need a macro to delete all shapes in a specified range of cells (C13:P35) on the first sheet of my workbook. I have a macro that does this and works perfectly when I just run it by itself. Here is the code:
Sub DeleteShapes()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If Not Intersect(shp.TopLeftCell, Range("C13:P35")) Is Nothing Then
shp.Delete
End If
Next shp
End Sub
My problem occurs when I want to run this macro along with others on Sheet1. Here is the code I am attempting to run:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$F$11" Then
Application.EnableEvents = False
If Target.Value = "100 - Pay Change" Then
Call ProtectionOff
Call DeleteShapes
Call PayChange
Call ProtectionOn
ElseIf Target.Value = "140 - Education Pay" Then
Call ProtectionOff
Call DeleteShapes
Call EducationPay
Call ProtectionOn
Application.EnableEvents = True
End If
End Sub
Running the above without the "Call DeleteShapes" in each scenario works perfectly. When I add "Call DeleteShapes" it tells me I have an error in this line of code from my DeleteShapes macro:
If Not Intersect(shp.TopLeftCell, Range("C13:P35")) Is Nothing Then
Again, I do not get an error when I run this DeleteShapes macro by itself, only when I "Call" it. I am using Excel 2010 and don't really have any experience with macros. Thank you for any help you can give!
Bookmarks