Clearing a Column range in Multiple Workbooks

R

Ruan

I have a command button on Sheet1 which I would like to use to clear
contents in a column range on Sheet1, Sheet2, and Sheet3. How do I do
this without Activating Sheet2 and Sheet3?


Code in the Sheet1 Module

Private Sub cmdClearCol5_Click()
ActiveSheet.Range("E11:E1000").ClearContents
[sheet2 code??]
[sheet3 code??]
End Sub

Thanks
Ruan
 
C

Chip Pearson

Ruan,

Try something like

Worksheets("Sheet1").Range("E11:E1000").ClearContents
Worksheets("Sheet2").Range("E11:E1000").ClearContents
Worksheets("Sheet3").Range("E11:E1000").ClearContents

If you want to clear the range on all worksheets, use a loop:

Dim WS As Worksheet
For Each WS In Worksheets
WS.Range("E11:E1000").ClearContents
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top