Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Create Tabs

'Try this but this will add a total of 31 tabs

Sub NameTheTabTodayAndNext31Days()
Dim dayofmonth As Integer
Dim movesheet As Integer


On Error GoTo Errhandler

dayofmonth = 1
movesheet = 4

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Sheets.Add
ActiveSheet.Name = Format(Now(), "[$-409]mmmm-dd-yyyy;@") '1
ActiveSheet.Move After:=Sheets(movesheet)
movesheet = movesheet + 1


Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '2
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '3
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '4
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '5
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '6
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '7
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '8
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '9
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '10
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '11
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '12
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '13
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1


Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '14
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '15
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '16
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '17
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '18
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '19
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '20
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '21
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '22
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '23
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '24
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '25
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1


Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '26
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '27
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '28
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '29
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '30
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets.Add
ActiveSheet.Name = Format(Now() + dayofmonth, "[$-409]mmmm-dd-yyyy;@") '31
ActiveSheet.Move After:=Sheets(movesheet)
dayofmonth = dayofmonth + 1
movesheet = movesheet + 1

Sheets(Array("Sheet3", "Sheet2", "Sheet1")).Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True


Errhandler:
If Err = 1004 Then
MsgBox "Error # " & Err & " : " & Error(Err)
ActiveSheet.Delete
End If

End Sub

"David T" wrote:

Is there a macro code that can automatically create the tabs based on the
number of days of the month?

"David T" wrote:

Is there any way I can create a new tab for every day of the month and name
that tab whatever the day of the month it is...ie Tab 1 will be named "1"
(for day 1) and Tab 2 will be name "2" (for day 2) and so on and so forth.

 
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
Create Tabs BoniM Excel Discussion (Misc queries) 0 March 28th 07 12:59 AM
create view tabs [email protected] Excel Worksheet Functions 3 November 7th 06 08:20 PM
Create tabs named after a group of cells? BM Excel Discussion (Misc queries) 3 September 26th 06 09:21 PM
How can Excel create a list of tabs on a worksheet? AliceNXLand Excel Discussion (Misc queries) 3 April 14th 05 05:23 PM
How can I create multiple rows of worksheet tabs in a workbook? kdzugan Excel Discussion (Misc queries) 1 March 8th 05 03:13 PM


All times are GMT +1. The time now is 06:57 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"