I have a workbook that has a hidden worksheet within.
There is a command button which I am trying to get working which copies the hidden sheet, places it at the end of all other sheets
then renames it.
I am trying to get the if exists error handling correct but I get error on "If WorksheetExists(wsName) Then"
If possible can some give me an idea why this is not working on my sheet.
For information, I have this method working perfectly in another workbook !
Version is Excel 2016
Sub AddWs() Dim i As Long, wsName As String, temp As String Sheets("Do Not Use").Copy After:=Sheets(Sheets.Count) wsName = "New Tennant" If WorksheetExists(wsName) Then temp = Left(wsName, 3) i = 1 wsName = temp & i Do While WorksheetExists(wsName) i = i + 1 wsName = temp & i Loop End If ActiveSheet.Name = wsName End Sub