ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Is there a way to name tabs so that they will ascend in order? (https://www.excelbanter.com/excel-worksheet-functions/115849-there-way-name-tabs-so-they-will-ascend-order.html)

madchef

Is there a way to name tabs so that they will ascend in order?
 
I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).

Gary''s Student

Is there a way to name tabs so that they will ascend in order?
 
Yes. It is very easy to sort them:

http://www.cpearson.com/excel/sortws.htm

--
Gary's Student


"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


Bob Phillips

Is there a way to name tabs so that they will ascend in order?
 
myDate = DateSerial(2006,1,1)
For i = 1 To Activeworkbook.worksheets.count
Worksheets(i).Name = Format(myDate,"mmm d")
myDate = myDate + 1
Next i

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"madchef" wrote in message
...
I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).




Dave Peterson

Is there a way to name tabs so that they will ascend in order?
 
Just a suggestion before you get too far into your workbook design.

You may want to use this variation of Bob's routine:

myDate = DateSerial(2006,1,1)
For i = 1 To Activeworkbook.worksheets.count
Worksheets(i).Name = Format(myDate,"yyyy_mm_dd")
myDate = myDate + 1
Next i

It'll make sorting the sheets much easier if you have to do this later.

madchef wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


--

Dave Peterson

romelsb

Is there a way to name tabs so that they will ascend in order?
 
I like this topic especially when dates are pre-determined....I like to do
this workbook design also yet considering only 6 days a week....hope we may
have this good for office dummie like me..........


"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


Dave Peterson

Is there a way to name tabs so that they will ascend in order?
 
Change the starting date, ending date and format--and the day to skip:

Option Explicit
Sub testme()

Dim iDate As Long

For iDate = DateSerial(2006, 1, 1) To DateSerial(2006, 5, 12)
If Weekday(iDate) = vbSunday Then
'do nothing
Else
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(iDate, "yyyy_mm_dd dddd")
End If
Next iDate
End Sub


romelsb wrote:

I like this topic especially when dates are pre-determined....I like to do
this workbook design also yet considering only 6 days a week....hope we may
have this good for office dummie like me..........

"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


--

Dave Peterson

romelsb

Is there a way to name tabs so that they will ascend in order?
 
Hello Dave...never been in VBE...hope u dont mind to teach me how and where
to paste everybody's good idea...thanks
--
"Bright minds are blessed to those who share them.."-rsb.


"Dave Peterson" wrote:

Change the starting date, ending date and format--and the day to skip:

Option Explicit
Sub testme()

Dim iDate As Long

For iDate = DateSerial(2006, 1, 1) To DateSerial(2006, 5, 12)
If Weekday(iDate) = vbSunday Then
'do nothing
Else
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(iDate, "yyyy_mm_dd dddd")
End If
Next iDate
End Sub


romelsb wrote:

I like this topic especially when dates are pre-determined....I like to do
this workbook design also yet considering only 6 days a week....hope we may
have this good for office dummie like me..........

"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


--

Dave Peterson


Dave Peterson

Is there a way to name tabs so that they will ascend in order?
 
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

=======

Short course:
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there. (But change the name from TestMe to something
significant.)

Now go back to excel to test it out.

Tools|Macro|macros|select that macro and click Run

Save your workbook before you run the macro--then if you have trouble, you can
close without saving and bring things back the way they were.

Note: DateSerial(2006, 1, 1) is dateserial(year#, month#, day#)



romelsb wrote:

Hello Dave...never been in VBE...hope u dont mind to teach me how and where
to paste everybody's good idea...thanks
--
"Bright minds are blessed to those who share them.."-rsb.

"Dave Peterson" wrote:

Change the starting date, ending date and format--and the day to skip:

Option Explicit
Sub testme()

Dim iDate As Long

For iDate = DateSerial(2006, 1, 1) To DateSerial(2006, 5, 12)
If Weekday(iDate) = vbSunday Then
'do nothing
Else
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(iDate, "yyyy_mm_dd dddd")
End If
Next iDate
End Sub


romelsb wrote:

I like this topic especially when dates are pre-determined....I like to do
this workbook design also yet considering only 6 days a week....hope we may
have this good for office dummie like me..........

"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).


--

Dave Peterson


--

Dave Peterson

romelsb

Is there a way to name tabs so that they will ascend in order?
 
thanks Dave..
--
"Bright minds are blessed to those who share them.."-rsb.


"Dave Peterson" wrote:

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

=======

Short course:
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there. (But change the name from TestMe to something
significant.)

Now go back to excel to test it out.

Tools|Macro|macros|select that macro and click Run

Save your workbook before you run the macro--then if you have trouble, you can
close without saving and bring things back the way they were.

Note: DateSerial(2006, 1, 1) is dateserial(year#, month#, day#)



romelsb wrote:

Hello Dave...never been in VBE...hope u dont mind to teach me how and where
to paste everybody's good idea...thanks
--
"Bright minds are blessed to those who share them.."-rsb.

"Dave Peterson" wrote:

Change the starting date, ending date and format--and the day to skip:

Option Explicit
Sub testme()

Dim iDate As Long

For iDate = DateSerial(2006, 1, 1) To DateSerial(2006, 5, 12)
If Weekday(iDate) = vbSunday Then
'do nothing
Else
Worksheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Format(iDate, "yyyy_mm_dd dddd")
End If
Next iDate
End Sub


romelsb wrote:

I like this topic especially when dates are pre-determined....I like to do
this workbook design also yet considering only 6 days a week....hope we may
have this good for office dummie like me..........

"madchef" wrote:

I am trying to label excel tabs so that they will go up automatically in
order (ie. Jan 1, Jan. 2, Jan. 3, etc).

--

Dave Peterson


--

Dave Peterson



All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com