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
 
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)
 
Back
Top