I have a worksheet where I want to create multiple worksheets with dates as the tab names. I want these tabs to copy data from another sheet and place it into each sheet created.
Code for creating sheets with dates as tab names:
(This works as expected, but I need to modify this code to copy the data in a specific sheet on each of the sheets that this macro creates)
The code is simple I am presuming but can not wrap my head around it.
Code for creating sheets with dates as tab names:
(This works as expected, but I need to modify this code to copy the data in a specific sheet on each of the sheets that this macro creates)
Code:
Sub DoDays()
Dim J As Integer
Dim K As Integer
Dim sDay As String
Dim sTemp As String
Dim iTarget As Integer
Dim dBasis As Date
iTarget = 13
While (iTarget < 1) Or (iTarget > 12)
iTarget = Val(InputBox("Numeric month?"))
If iTarget = 0 Then Exit Sub
Wend
Application.ScreenUpdating = False
sTemp = Str(iTarget) & "/1/" & Year(Now())
dBasis = CDate(sTemp)
For J = 1 To 31
sDay = Format((dBasis + J - 1), "mm-dd-yy")
If Month(dBasis + J - 1) = iTarget Then
If J <= Sheets.Count Then
If Left(Sheets(J).Name, 5) = "Sheet" Then
Sheets(J).Name = sDay
Else
Sheets.Add.Move after:=Sheets(Sheets.Count)
ActiveSheet.Name = sDay
End If
Else
Sheets.Add.Move after:=Sheets(Sheets.Count)
ActiveSheet.Name = sDay
End If
End If
Next J
For J = 1 To (Sheets.Count - 1)
For K = J + 1 To Sheets.Count
If Right(Sheets(J).Name, 10) > _
Right(Sheets(K).Name, 10) Then
Sheets(K).Move Before:=Sheets(J)
End If
Next K
Next J
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub
The code is simple I am presuming but can not wrap my head around it.