OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 421
- Office Version
- 2019
- Platform
- Windows
Thanks in advance. I will give feedback on whether any proposed solutions work or not.
I have a sheet titled "Menu" and in column B of that sheet I have names of the new Tabs I want to make. The names are in the format "2020.12.30" or "2020.12.31" I want to insert the new tabs between the existing tab "START" and "END." My code is as follows and I'm getting a "compile error" on the following line:
I understand there are far more efficient and advanced ways to write the code, but to ensure I understand it if changes need to be made, please modify my code as little as possible.
I have a sheet titled "Menu" and in column B of that sheet I have names of the new Tabs I want to make. The names are in the format "2020.12.30" or "2020.12.31" I want to insert the new tabs between the existing tab "START" and "END." My code is as follows and I'm getting a "compile error" on the following line:
VBA Code:
Sht_Start = Sheets("WL.START").Index
I understand there are far more efficient and advanced ways to write the code, but to ensure I understand it if changes need to be made, please modify my code as little as possible.
VBA Code:
Sub WL_Sheets_Insert()
Dim LastRowColA As Long
Dim Sht_Start As Sheets
Dim Date1 As String
Dim i As Long
'Date1 stores the value in the format "YYYY.MM.DD" such as 2020.12.30, but it's not in an actual date format.
'___________________________
Sheets("Menu").Activate
'Sheets(1) = Sheets("START")
LastRowColA = Sheets("WL.Menu").Cells(Rows.Count, 1).End(xlUp).Row
Sht_Start = Sheets("WL.START").Index
'___________________________
For i = Sht_Start + 1 To LastRowColA
WL_Date = Sheets(Menu).Cells(i, 2).Value
Sheets.Add(After:=Sheets(i - 1)).Name = Date1
Sheets(i).Name = Date1
Next i
End Sub