PC Review


Reply
Thread Tools Rate Thread

Delete row 1 in all worksheets

 
 
Jodie
Guest
Posts: n/a
 
      29th Dec 2009
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?
--
Thank you, Jodie
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      29th Dec 2009
Right click sheet tab>select all sheets>delete on one deletes all

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Jodie" <(E-Mail Removed)> wrote in message
news:9E1AEF56-DFFA-46F7-8ED9-(E-Mail Removed)...
>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?
> --
> Thank you, Jodie


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      29th Dec 2009
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

--
Rick (MVP - Excel)


"Jodie" <(E-Mail Removed)> wrote in message
news:9E1AEF56-DFFA-46F7-8ED9-(E-Mail Removed)...
>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?
> --
> Thank you, Jodie


 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      29th Dec 2009

You could try :

For nCount = 1 To Sheets.Count
Worksheets(nCount).Rows("1:1").Delete shift:=xlUp
Next

--
If the post is helpful, please consider donating something to an animal
charity on my behalf.


"Jodie" wrote:

> 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?
> --
> Thank you, Jodie

 
Reply With Quote
 
Jodie
Guest
Posts: n/a
 
      29th Dec 2009
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.
--
Thank you, Jodie


"Don Guillett" wrote:

> Right click sheet tab>select all sheets>delete on one deletes all
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Jodie" <(E-Mail Removed)> wrote in message
> news:9E1AEF56-DFFA-46F7-8ED9-(E-Mail Removed)...
> >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?
> > --
> > Thank you, Jodie

>
> .
>

 
Reply With Quote
 
Jodie
Guest
Posts: n/a
 
      29th Dec 2009
Thanks Paul, this is exactly what I need.
--
Thank you, Jodie


"Paul" wrote:

>
> You could try :
>
> For nCount = 1 To Sheets.Count
> Worksheets(nCount).Rows("1:1").Delete shift:=xlUp
> Next
>
> --
> If the post is helpful, please consider donating something to an animal
> charity on my behalf.
>
>
> "Jodie" wrote:
>
> > 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?
> > --
> > Thank you, Jodie

 
Reply With Quote
 
Jodie
Guest
Posts: n/a
 
      29th Dec 2009
Rick, I needed the code to add to a macro that I wrote for other functions.
--
Thank you, Jodie


"Rick Rothstein" wrote:

> 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
>
> --
> Rick (MVP - Excel)
>
>
> "Jodie" <(E-Mail Removed)> wrote in message
> news:9E1AEF56-DFFA-46F7-8ED9-(E-Mail Removed)...
> >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?
> > --
> > Thank you, Jodie

>
> .
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      29th Dec 2009
>> For nCount = 1 To Sheets.Count
>> Worksheets(nCount).Rows("1:1").Delete shift:=xlUp
>> Next


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.

--
Rick (MVP - Excel)


"Jodie" <(E-Mail Removed)> wrote in message
news:CF6819C5-184B-4257-83D2-(E-Mail Removed)...
> Thanks Paul, this is exactly what I need.
> --
> Thank you, Jodie
>
>
> "Paul" wrote:
>
>>
>> You could try :
>>
>> For nCount = 1 To Sheets.Count
>> Worksheets(nCount).Rows("1:1").Delete shift:=xlUp
>> Next
>>
>> --
>> If the post is helpful, please consider donating something to an animal
>> charity on my behalf.
>>
>>
>> "Jodie" wrote:
>>
>> > 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?
>> > --
>> > Thank you, Jodie


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Worksheets Sal Microsoft Excel Programming 4 7th May 2009 01:41 AM
Delete All Worksheets Apart From Some With Particular Name =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Misc 1 31st Oct 2007 01:30 AM
Delete All Worksheets, Except for Three =?Utf-8?B?cnlndXk3Mjcy?= Microsoft Excel Programming 1 16th Mar 2007 04:19 PM
I can't delete my worksheets =?Utf-8?B?Y2h1Y2ttY2M=?= Microsoft Excel Programming 7 17th Mar 2006 10:11 PM
Delete worksheets andym Microsoft Excel Programming 6 24th Nov 2003 04:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.