MAcro to clear all contents

wowkiter

New Member
Joined
May 14, 2002
Messages
2
Hi all! I need a macro to clear the data fields in a workbook with 12 sheets of varying sizes (if that matters?).
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Sub Jack()
' Written by Jack in the UK 16th May 2002
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
' Add in sheets / name of all sheets upto 12
Sheets("Sheet1").Activate
'just makes something active so code executes OK
Selection.ClearContents
' Cleasr cells contence in one hit - gone
Sheet1.Select
Range("A1").Select
' just select any cell in sheet1 or whatever you name,
' I like to finish on a cell of some sort


End Sub
 
Upvote 0
What do you mean by data fields? Cells?

If it's just cells, you don't have to select anything using:<pre>
Sub clearly()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.UsedRange.ClearContents
Next ws
End Sub</pre>

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
wave.gif

This message was edited by NateO on 2002-05-15 11:55
 
Upvote 0
Jack,
Its good to see commented code! If more people did it everyone would learn alot more.
 
Upvote 0
ermmm

i copy a few guys really im very poor at scripts, i have folowed a guy call joe was he seem to know a bit

Dave Hawley is my old pal, and my great friend Ivan F Moala these guys i like the style they use.. not taking a thing from the other GURUS, Mark suport Celtic so we call all ignor him even thou: hes MVP

I keep saying Celtic will never win the world cup, and Mark swares he wares a skirt!
 
Upvote 0
Me to Jack, Dave Hawley amazes me as does Ivan F Moala and I find Nate-O equally helpful. Aladdin as a sheet function man is the best I have ever seen. On the old board Dave helped me with some tough problems.

Mark O'Brien does good snippets and helps regularly. I should have remembered him right off, my wifes grandmother was an O'Brien. Juan writes killer code as well and knows some obscure tricks as well. So many people help out on this board that one could go on all day thanking the experts. JSW
This message was edited by Joe Was on 2002-05-16 11:43
This message was edited by Joe Was on 2002-05-16 11:44
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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