Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code below that a member here at Mr Excel provided me to clear any shapes that might remain in my workspace after I clear the cell contents in range ("J3:BM1102")
I have shapes at H3, H4, and H5 that I want to keep. Does the code above delete them also. I'm guessing it does as I seem to be unable to keep them. If this code is indeed deleting them, how can I change this code to only delete shapes within the Range("J3:BM1102")?
Code:
rivate Sub Workbook_Open()
'Stop
ini1
svcCnt = 0
svcRid = 0
mbevents = True
'Stop
With ws_front
.Activate
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1
.Unprotect
With ws_front.Range("J3:BM1102")
.Clear
For Each shp In .Parent.Shapes
If Not Intersect(shp.TopLeftCell, .Cells) Is Nothing Then shp.Delete
Next shp
End With
mbevents = False
.Range("A1") = "Enter Date"
.Range("A2") = Format(0, "00000") 'date serial
.Range("D2") = Format(0, "000") 'record
.Range("E2:F2").Locked = True
.Range("E2") = svcRid
.Range("G2") = svcCnt
.Range("A3:A5") = ""
.Shapes("hidden1").Visible = False
.Shapes("hidden2").Visible = False
.Shapes("hidden3").Visible = False
.Range("M1,O1,M2,O2,U1,U2,W1,W2,AD1, AD1, AD2,AF1, AF2") = 0
ws_staff.Range("D4:M33").Clear
mbevents = True
.Protect
End With
End Sub
I have shapes at H3, H4, and H5 that I want to keep. Does the code above delete them also. I'm guessing it does as I seem to be unable to keep them. If this code is indeed deleting them, how can I change this code to only delete shapes within the Range("J3:BM1102")?