Delete row 1 in all worksheets

  • Thread starter Thread starter Jodie
  • Start date Start date
J

Jodie

I think this is simple, but I can't get it to work. I need to write a macro
to delete row 1 of all worksheets in a workbook. Can someone please help?
 
If there is a reason you need this in code (as opposed to Don's manual
method), use this code in your own macro...

Dim WS As Worksheet
.......
.......
For Each WS In ThisWorkbook.Worksheets
WS.Rows(1).Delete
Next
 
You could try :

For nCount = 1 To Sheets.Count
Worksheets(nCount).Rows("1:1").Delete shift:=xlUp
Next
 
Don, I was trying to write this in a macro. When I recorded the macro, it
included the names of the sheets. This would not work in my macro because
the sheet names would be different every time I use it.
 
For nCount = 1 To Sheets.Count
If you are going to use this construction (as opposed to the For Each method
I posted), then you should change the Sheets.Count reference in the For
statement to Worksheets.Count; otherwise, if you have a Chart sheet in your
workbook, you will get an error as there will be more sheets than
worksheets.
 
Back
Top