From: JStiehl on
I need help with VBA code to sort tab names with numbers in order, but leave
the ones with words as they are. Tab names with numbers should precede the
tabs with words. I have searched and can only find codes to sort
alphanumerically. Thanks for your help.

Example of what order I would like my tabs in:

123890
456678
789123
Project1
Project2
Project3
Total
Findings
From: Don Guillett on
http://support.microsoft.com/kb/812386

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett(a)gmail.com
"JStiehl" <JStiehl(a)discussions.microsoft.com> wrote in message
news:419F7C3A-D76E-420C-A635-45F258670062(a)microsoft.com...
>I need help with VBA code to sort tab names with numbers in order, but
>leave
> the ones with words as they are. Tab names with numbers should precede
> the
> tabs with words. I have searched and can only find codes to sort
> alphanumerically. Thanks for your help.
>
> Example of what order I would like my tabs in:
>
> 123890
> 456678
> 789123
> Project1
> Project2
> Project3
> Total
> Findings

From: Bob Phillips on
See http://www.cpearson.com/excel/sortws.aspx

--

HTH

Bob

"JStiehl" <JStiehl(a)discussions.microsoft.com> wrote in message
news:419F7C3A-D76E-420C-A635-45F258670062(a)microsoft.com...
>I need help with VBA code to sort tab names with numbers in order, but
>leave
> the ones with words as they are. Tab names with numbers should precede
> the
> tabs with words. I have searched and can only find codes to sort
> alphanumerically. Thanks for your help.
>
> Example of what order I would like my tabs in:
>
> 123890
> 456678
> 789123
> Project1
> Project2
> Project3
> Total
> Findings


From: Jacob Skaria on
Try

Sub Macro()
Dim lngCount1 As Long, lngCount2 As Long
For lngCount1 = 1 To Sheets.Count - 1
For lngCount2 = lngCount1 + 1 To Sheets.Count
If IsNumeric(Sheets(lngCount1).Name) And _
IsNumeric(Sheets(lngCount2).Name) Then
If CCur(Sheets(lngCount1).Name) > CCur(Sheets(lngCount2).Name) Then _
Sheets(lngCount1).Move After:=Sheets(lngCount2): Exit For
End If
Next
Next
End Sub


--
Jacob (MVP - Excel)


"JStiehl" wrote:

> I need help with VBA code to sort tab names with numbers in order, but leave
> the ones with words as they are. Tab names with numbers should precede the
> tabs with words. I have searched and can only find codes to sort
> alphanumerically. Thanks for your help.
>
> Example of what order I would like my tabs in:
>
> 123890
> 456678
> 789123
> Project1
> Project2
> Project3
> Total
> Findings
From: Jacob Skaria on
Try this instead..

Sub Macro()
Dim lngCount1 As Long, lngCount2 As Long
For lngCount1 = 1 To Sheets.Count
For lngCount2 = lngCount1 + 1 To Sheets.Count
If Sheets(lngCount1).Name > Sheets(lngCount2).Name Then _
Sheets(lngCount1).Move After:=Sheets(lngCount2): Exit For
Next
Next
End Sub


--
Jacob (MVP - Excel)


"Jacob Skaria" wrote:

> Try
>
> Sub Macro()
> Dim lngCount1 As Long, lngCount2 As Long
> For lngCount1 = 1 To Sheets.Count - 1
> For lngCount2 = lngCount1 + 1 To Sheets.Count
> If IsNumeric(Sheets(lngCount1).Name) And _
> IsNumeric(Sheets(lngCount2).Name) Then
> If CCur(Sheets(lngCount1).Name) > CCur(Sheets(lngCount2).Name) Then _
> Sheets(lngCount1).Move After:=Sheets(lngCount2): Exit For
> End If
> Next
> Next
> End Sub
>
>
> --
> Jacob (MVP - Excel)
>
>
> "JStiehl" wrote:
>
> > I need help with VBA code to sort tab names with numbers in order, but leave
> > the ones with words as they are. Tab names with numbers should precede the
> > tabs with words. I have searched and can only find codes to sort
> > alphanumerically. Thanks for your help.
> >
> > Example of what order I would like my tabs in:
> >
> > 123890
> > 456678
> > 789123
> > Project1
> > Project2
> > Project3
> > Total
> > Findings