I am trying to set up a macro that when run will auto-create new sheets with names of dates in chronological order. EX: 06/01, 06/02 and fill the cells with data from a "Template" sheet. The macro currently will create these sheets in reverse order such as 06/30, 06/29..etc. How do I make it start from 06/01...06/30 instead of 06/30...06/01 with the new named sheets created?
I have tried the code listed below. Along with changing the
Sheets("Temp").Range("d5").Value = Sheets("Temp").Range("a5") - X
to
Sheets("Temp").Range("d5").Value = Sheets("Temp").Range("a5") + X
Setting up the code in VB for Temp Sheet:
--Start--
Sub Dtpopulate()
Dim S As Integer
Dim X As Integer
S = Sheets("Temp").Range("c5").Value
For X = 1 To S
newname = Sheets("Temp").Range("a6").Value
Worksheets("Template").Activate
Sheets("Template").Cells.Select
Selection.Copy
Sheets.Add.Name = newname
Sheets(newname).Cells.Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Temp").Range("d5").Value = Sheets("Temp").Range("a5") - X
Next X
End Sub
--Finish--
I expected the sheets to be created and auto-filled with the data from "Templates" and each sheet to be named 06/01...06/30, but the output are sheets named 06/30 to 06/01.