Forum Discussion
Spring_Hebler
Feb 01, 2024Copper Contributor
Using Excel Spreadsheet to log calls by month, where each tab is a day of the month (M-F)
Is it possible to auto fill the tabs to be the days (ex: Feb 1, Feb 2, Feb 3), and each tab to have a cell with the same date formatted (ex: 1-Feb-24, 2-Feb-24, 3-Feb-24)? Is it possible to further d...
sivakumarrj
Feb 07, 2024Brass Contributor
To automate insert sheets, better to use VBA, here I have given code for inserting March 2024,
Sub InsertMarch2024Tabs()
' Set the desired month and year
Const DesiredMonth As Integer = 3
Const DesiredYear As Integer = 2024
' Get the start date of the desired month
Dim StartDate As Date
StartDate = DateSerial(DesiredYear, DesiredMonth, 1)
' Determine the number of days in the desired month
Dim DaysInMonth As Integer
DaysInMonth = Day(DateSerial(DesiredYear, DesiredMonth + 1, 0))
' Loop through each day of the month
Dim i As Integer
For i = 1 To DaysInMonth
' Add a new worksheet
Sheets.Add After:=Sheets(Sheets.Count)
' Name the worksheet with the current date in "dd-mmm-yyyy" format
ActiveSheet.Name = Format(StartDate + i - 1, "dd-mmm-yyyy")
Next i
End Sub
Before that, please make sure that proper changes for specific months to insert sheets in worksheet.
Thanks
Sub InsertMarch2024Tabs()
' Set the desired month and year
Const DesiredMonth As Integer = 3
Const DesiredYear As Integer = 2024
' Get the start date of the desired month
Dim StartDate As Date
StartDate = DateSerial(DesiredYear, DesiredMonth, 1)
' Determine the number of days in the desired month
Dim DaysInMonth As Integer
DaysInMonth = Day(DateSerial(DesiredYear, DesiredMonth + 1, 0))
' Loop through each day of the month
Dim i As Integer
For i = 1 To DaysInMonth
' Add a new worksheet
Sheets.Add After:=Sheets(Sheets.Count)
' Name the worksheet with the current date in "dd-mmm-yyyy" format
ActiveSheet.Name = Format(StartDate + i - 1, "dd-mmm-yyyy")
Next i
End Sub
Before that, please make sure that proper changes for specific months to insert sheets in worksheet.
Thanks