LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default For Each...won't loop through worksheets

What am I missing here? Below is some copy/pasted code in an attempt to have
a Sub run on each worksheet of a workbook. I have some more involved
reformatting routines that I'd like to run as well on these sheets, but I
figured I'd start here. I can't seem to get past a basic point.

I know there are more ways than one to skin this cat & I'm not in good form
w/o declarations - please indulge me...

When this code runs in a workbook with worksheets named:

Summary, Sun, Mon, Tue, Wed, Thu, Fri, Sat

....it only does anything if the active sheet is something other than
'Summary' and then it deletes 7 rows from the Active sheet. What am I
missing that's not allowing the first row of each sheet to be deleted (I
actually want to delete the first 11).

Sub DeleteOldHeader()

Dim sht As Worksheet

Dim target As Worksheet

Set target = ActiveWorkbook.Worksheets("Summary")

For Each sht In Worksheets

If sht.Name < target.Name Then

Rows(1).Delete

End If

Next sht

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop worksheets merry_fay Excel Discussion (Misc queries) 2 January 7th 09 01:54 PM
Naming worksheets in loop Jenni_Sweden Excel Programming 3 June 15th 06 12:59 PM
Loop thru some worksheets Mike Fogleman Excel Programming 2 August 21st 05 12:22 AM
Loop Through worksheets Stephen[_9_] Excel Programming 5 April 20th 04 01:46 PM
Loop worksheets Steve[_35_] Excel Programming 3 November 25th 03 04:46 AM


All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"