How to delete same column in every sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to delete the contents of every column H in the whole work
book using a command button
 
For each sh In Activeworkbook.Worksheets
sh.Column(8).ClearContents
Next sh

--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Looks like it should work but it doesnt

I created a button, viewed the code and inserted this:

Private Sub Clear_Click()
For Each sh In ActiveWorkbook.Worksheets
sh.Column(8).ClearContents
Next sh

End Sub

The Debug screen shows it failing on sh.Column(8).ClearContents
object doesnt support this method or property
 
Hi

try inserting sh.activate immediately inside the loop

Private Sub Clear_Click()
For Each sh In ActiveWorkbook.Worksheets
sh.activate
sh.Column(8).ClearContents
Next sh

End Sub
 
I had a typo, it should be


For each sh In Activeworkbook.Worksheets
sh.Columns(8).ClearContents
Next sh



--
---
HTH

Bob

__________________________________________
UK Cambridge XL Users Conference 29-30 Nov
http://www.exceluserconference.com/UKEUC.html

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Or without VBA...
Select column H
Right-click the tab of that sheet
 

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

Back
Top