ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create a Month's Sheets automatically (https://www.excelbanter.com/excel-programming/429243-create-months-sheets-automatically.html)

PumaMan

Create a Month's Sheets automatically
 
I was wondering if there's a procedure to automatically add sheets for the
days in a month automatically? The format just needs the month and day, but
I'd like to be able to do it with VBA.

Thanks!

Patrick Molloy

Create a Month's Sheets automatically
 
Option Explicit
Sub AddSheets()
Dim mn As Long
Dim dy As Date
Dim ws As Worksheet
Do
mn = InputBox("Enter Month (0 to quit)")
Loop Until mn = 0 And mn <= 13

If mn = 0 Then Exit Sub

For dy = DateSerial(Year(Date), mn, 1) To DateSerial(Year(Date), mn + 1,
0)
Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
ws.Name = Format$(dy, "DD_MMM")
Next
End Sub

"PumaMan" wrote in message
...
I was wondering if there's a procedure to automatically add sheets for the
days in a month automatically? The format just needs the month and day,
but
I'd like to be able to do it with VBA.

Thanks!




All times are GMT +1. The time now is 02:06 PM.

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