View Full Version : VBA code to delete cell ranges
rich_cirillo
07-08-2013, 06:59 AM
Hi
I require a VBA code to delete the following cell ranges
D3:N9
D13:N19
D23:N29
D33:N39
D43:N49
D53:N59
D63:N69
all the way down to
D273:N279
Sheet name is Score
Thanks
Rich
bakerman
07-08-2013, 07:15 AM
Sub DeleteRanges()
With Sheets("Score")
For i = 3 To 273 Step 10
.Range("D" & i).Resize(7, 11).ClearContents
Next
End With
End Sub
rich_cirillo
07-08-2013, 08:11 AM
thanks
Can you add a message box before deleting which says "are you sure you want to delete data"
Thanks
Rich
bakerman
07-08-2013, 09:18 AM
This really wasn't so hard, not ?
Sub DeleteRanges()
If MsgBox("Are you sure you want to delete data ?", vbYesNoCancel + vbExclamation, "Delete data") = vbYes Then
With Sheets("Score")
For i = 3 To 273 Step 10
.Range("D" & i).Resize(7, 11).ClearContents
Next
End With
End If
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.