Delete Row 1 from every sheet in a workbook

  • Thread starter Thread starter EeOr
  • Start date Start date
E

EeOr

Hi I would like to loop through every sheet in a wrokbook and delete row 1
from it, I currently have the following code:

Dim sht As Worksheet
For Each sht In Sheets
Rows(1).Delete
X = X + 1
Next sht
MsgBox "Workbook contains " & X " Sheets", vbOKOnly

When this code is run it is deleting row 1 from the same sheet based on the
number of sheets I have so for example if I have 13 sheets it will delete 13
rows from sheet 13 instead of row 1 from all sheets. Can someone please
show me where I am going wrong?

Thanks

jon
 
Qualify the Rows, and use Worksheets not Sheets, Charts don't have rows.

Dim sht As Worksheet
For Each sht In Activeworkbook.Worksheets
sht.Rows(1).Delete
X = X + 1
Next sht
MsgBox "Workbook contains " & X " Sheets", vbOKOnly


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Back
Top