How to create worksheet with the name "Jan. 2007".....
Private Sub SchedSheets()
Dim mon As String Dim monArr() As String Dim m As Long mon = "Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.D ec" monArr = Split(mon, ".") Dim ws As Worksheet Dim mm As Integer Dim i As Integer i = 3 Dim sheetName As String For m = 0 To 11 sheetName = monArr(m) & " " & Year(Date) Worksheets.Add after:=Sheets(i) ActiveSheet.Name = sheetName i = i + 1 Next m End Sub -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Jeffery B Paarsa" wrote in message ... Hello all, In a VBA macro I running the following code hoping to create a maximum number of 12 worksheets after worksheet number 3 with the worksheet name of "Jan. 2007", "Feb. 2007"....etc... What am I doing wrong... Beleive me I spent at least 2 hours in search to find an example code with no success.... Private Sub SchedSheets() Dim mon As String Dim monArr() As String mon = "Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.D ec." monArr = Split(mon, ".") Dim ws As Worksheet Dim mm As Integer Dim i As Integer i = 3 m = Month(Date) Dim sheetName As String While mm < 13 sheetName = monArr(m) & " " & Year(Date) Worksheets.Add after:=Sheets(i) ActiveWorksheet.Name = sheetName i = i + 1 m = m + 1 Wend End Sub -- Jeff B Paarsa |
All times are GMT +1. The time now is 01:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com