ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What could be wrong? (https://www.excelbanter.com/excel-programming/379929-re-what-could-wrong.html)

Don Guillett

What could be wrong?
 
try this
Sub yearofsheets()
myear = InputBox("Enter year ie: " & Year(Date))
For i = 1 To 12
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = Format(DateSerial(myear, i, 1), "mmm yyyy")
Next i
End Sub

--
Don Guillett
SalesAid Software

"Playing WMA files in squence"
m wrote in message
...
Hello,

In a While loop I am trying to create a few Worksheets and rename them as
"Jan. 2006" or "Jul. 2006" etc... Here is what I have in an array of
string:
Dim mon As String
Dim monArr() As String
mon = "Jan. Feb. Mar. Apr. May. Jun. Jul. Aug. Sep. Oct. Nov. Dec. "
monArr = Split(mon, " ")

In the While loop I execute the following code if m is less than 13.
sheetName = monArr(m) & Year(Date)
MsgBox sheetName
Worksheets.Add after:=Sheets(i)
ActiveSheet.Name = sheetName

I get the dialog box displaying "2006" and my sheet name is named as
"2006"!
On the statement "sheetName = monArr(m) & Year(Date)" when m=1,2,3 or
...12, what is wrong that I do not get "Jan. 2006" or "Feb. 2006".... etc
on
the MsgBox sheetName or "Jan. 2006" or "Feb, 2006" for as name for my
Worksheet?







All times are GMT +1. The time now is 05:40 PM.

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