Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OK -- I need to sort worksheets in

Status
Not open for further replies.

qleader

Technical User
Dec 20, 2001
31
0
0
US
OK -- I need to sort worksheets in excel with a macro. Ihave about hundred worksheet in one workbook. When we add a new worksheet I need to then be sorted. They are numbered sheet with the expection of one called "master sheet" One last thing- the one called "master sheet" needs to stay at the beging of the numbered sheets.

This is what I came up with but it sorts the master sheet to end.
Dim Cnt%, A%, B%

Cnt = ActiveWorkbook.Worksheets.Count
For B = 1 To Cnt
For A = B To Cnt
If Worksheets(A).Name < Worksheets(B).Name Then
Worksheets(A).move Before:=Worksheets(B)
End If
Next A
Next B

Any ideas......
 
[tt]Try this, rename

master sheet to
' master sheet[/tt]

&quot;The reward of one duty done is the power to fulfill another&quot;
J R C L [jester] W N


 

How about add a line after your code:

Worksheets(&quot;Master&quot;).Move before:=Worksheets(1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top