Macro To Clear Same Cell Ranges From Multiple Sheets

tjeacret

New Member
Joined
Oct 22, 2010
Messages
22
Hello! This is my first post but I have used this site many times in the past. I have a question I need help with. I have an excel workbook that has a master sheet, two data tabs and 15 user tabs. I need a macro/code that will do the following:

Clear sheet2 with data range A1:N20
Clear sheet3 with data range A1:E20
Clear sheet4 thru sheet18 with data range B2:E25 on each sheet
Return to sheet1 on cell A1

I need this to run based on the sheets not the sheet names because I have multiple copies that different users use and change the sheet names. Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try this

Code:
Sub Clear()
Dim i As Long
Sheets(2).Range("A1:N20").ClearContents
Sheets(3).Range("A1:E20").ClearContents
For i = 4 To 18
    Sheets(i).Range("B2:E25").ClearContents
Next i
End Sub
 
Upvote 0
Try this

Code:
Sub Clear()
Dim i As Long
Sheets(2).Range("A1:N20").ClearContents
Sheets(3).Range("A1:E20").ClearContents
For i = 4 To 18
    Sheets(i).Range("B2:E25").ClearContents
Next i
End Sub

Hello, I am trying to do the same thing and I changed your code to reflect my needs but it is not working any help?
My Sheets are named as 31 - 2nd, 31 - 1st, 31 - 3rd, 30 - 2nd, 30 - 1st, 30 - 3rd, 29 - 2nd, 29 - 1st, 29 - 3rd.... all the way down to 1 - 2nd, 1 - 1st, 1 - 3rd my code looks as below

Code:
Sub Clear()

Sheets("1 - 3rd").Select

Dim i As Long

For i = "31 - 2nd" To "1 - 3rd"
    Sheets(i).Range("C8:O9,C11:O14,C18:O20,C29:O29,C39:O41,C43:O45,C51:O51,B75:R118").ClearContents
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top