I am new to VBA and currently working on a dashboard-ish project. My code needs to create a new tab to store downloaded data from a SQL database AND rename the tab as "Financial_Data_MM-DD-YY" where MM-DD-YY represent the current date.
What I have already complete is displayed below. Can anyone help a brotha out and explain how to add text into this naming convention?
Sub CreateRenameDataSheet()
Dim i As Integer, Cntr As Integer
Sheets.Add
For i = 1 To Sheets.Count
If Left(Sheets(i).Name, 10) = Format(Date, "DD-MM-YYYY") Then
Cntr = Cntr + 1
End If
Next
If Cntr = 0 Then
ActiveSheet.Name = Format(Date, "DD-MM-YYYY")
Else
ActiveSheet.Name = Format(Date, "DD-MM-YYYY") & " (" & Cntr & ")"
End If
End Sub
Bookmarks