Hi,
I'm trying to write a basic macro that will check to see if a specified sheet already exists ("SheetList") and delete it if it does, before re-adding a sheet and then listing the names of all sheets. I've got this:
Sub ListWorkSheetNames()
Dim Sheets
Dim Sheetnames
If Sheets = ("SheetList") Then
Sheets("SheetList").Select
ActiveWindow.SelectedSheets.Delete
End If
Sheetnames = Sheets.Count
Sheets.Add
ActiveSheet.Name = "SheetList"
Sheets("SheetList").Move after:=Sheets(Sheetnames + 1)
For i = 1 To Sheetnames
Range("A" & i) = Sheets(i).Name
Next i
End Sub
But it keeps returning Runtime Error 424 - Object Required.
Any help here would be appreciated!
Thanks,
Sean
I'm trying to write a basic macro that will check to see if a specified sheet already exists ("SheetList") and delete it if it does, before re-adding a sheet and then listing the names of all sheets. I've got this:
Sub ListWorkSheetNames()
Dim Sheets
Dim Sheetnames
If Sheets = ("SheetList") Then
Sheets("SheetList").Select
ActiveWindow.SelectedSheets.Delete
End If
Sheetnames = Sheets.Count
Sheets.Add
ActiveSheet.Name = "SheetList"
Sheets("SheetList").Move after:=Sheets(Sheetnames + 1)
For i = 1 To Sheetnames
Range("A" & i) = Sheets(i).Name
Next i
End Sub
But it keeps returning Runtime Error 424 - Object Required.
Any help here would be appreciated!
Thanks,
Sean