Clear contents in multiple sheets on same workbook macro

PuntingJawa

Board Regular
Joined
Feb 25, 2021
Messages
140
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have created a verification workbook. I am trying to generate a macro to clear content from multiple sheets. Currently having issues with what I have found, so asking here. I'll break down what some ranges are for an example.
Sheet (PSI MAIN)
B7:F1048576
Sheet (PSI OTHER)
B6:AJ1048576
Sheet (MLS)
C3:C32, E3:E32, G3:G32, I3:I32, K3:K32, M3:M32, O3:O32, Q3:Q32, C34:C63, E34:E63, G34:G63, I34:I63, K34:K63, M34:M63, O34:O63, Q34:Q63, T3:T32

I can do the rest myself as all the other ranges are roughly the same. I just need somewhere to start to see the pattern changes and the ranges above give me enough of a difference.
As always, thank you in advance Mr.Excel board!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
try
VBA Code:
Worksheets("PSI MAIN").Range("B7:F1048576").ClearContents
Worksheets("PSI OTHER").Range("B6:AJ1048576").ClearContents
Worksheets("MLS").Range("C3:C32, E3:E32, G3:G32, I3:I32, K3:K32, M3:M32, O3:O32, Q3:Q32, C34:C63, E34:E63, G34:G63, I34:I63, K34:K63, M34:M63, O34:O63, Q34:Q63, T3:T32").ClearContents
 
Upvote 1
try
VBA Code:
Worksheets("PSI MAIN").Range("B7:F1048576").ClearContents
Worksheets("PSI OTHER").Range("B6:AJ1048576").ClearContents
Worksheets("MLS").Range("C3:C32, E3:E32, G3:G32, I3:I32, K3:K32, M3:M32, O3:O32, Q3:Q32, C34:C63, E34:E63, G34:G63, I34:I63, K34:K63, M34:M63, O34:O63, Q34:Q63, T3:T32").ClearContents
Thanks! With what you gave, I made it work. What I had was exactly what you have there but I could not get it to work. Strangely a copy and paste was enough to get me started. It's also possible that I was not seeing a typographical error in the debugging lines. Much appreciated.
VBA Code:
Sub ClearData()
Worksheets("PSI MAIN").Range("B7:F1048576").ClearContents
Worksheets("PSI OTHER").Range("B6:AJ1048576").ClearContents
Worksheets("MLS").Range("C3:C32, E3:E32, G3:G32, I3:I32, K3:K32, M3:M32, O3:O32, Q3:Q32, C34:C63, E34:E63, G34:G63, I34:I63, K34:K63, M34:M63, O34:O63, Q34:Q63, T3:T32").ClearContents
Worksheets("DMCU").Range("C3:C32, E3:E32, G3:G32, I3:I32, K3:K32").ClearContents
Worksheets("SLRU").Range("C3:C32, E3:E32, G3:G32, I3:I32, K3:K32").ClearContents
Worksheets("HARNESS").Range("C3:C45, E3:E45, G3:G45, I3:I45, K3:K45, M3:M45, O3,O45, Q3:Q45").ClearContents
Worksheets("GLIN").Range("C3:C52, E3:E52, G3:G52, I3:I52, K3:K52, M3:M52, O3:O52, Q3:Q52, S3:S12").ClearContents
Worksheets("OTHER").Range("C3:C52, E3:E52, G3:G52, I3:I52, K3:K52, M3:M52, O3:O52, Q3:Q52").ClearContents
Worksheets("DO").Range("C4:C33, E4:E33, G4:G33, I4:I33, K4:K33, C37:C66, E37:E66, G37:G66, I37:I66, K37:K66").ClearContents
Worksheets("DH").Range("C4:C33, E4:E33, G4:G33, I4:I33, K4:K33, C36:C65, E36:E65, G36:G65, I36:I65, K36:K65").ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,201
Messages
6,123,617
Members
449,109
Latest member
Sebas8956

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