Hi all,
I'm using the following code to delete a sheet if found. Its throwing an error, when it is found and deleted. Need to understand how to recalculate the sheets count in a loop as such. Please help
Sht_Cnt = ActiveWorkbook.Sheets.Count
For i = 1 To Sht_Cnt
If Sheets(i).Name = "Dummy" Then
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
End If
Next i
I'm using the following code to delete a sheet if found. Its throwing an error, when it is found and deleted. Need to understand how to recalculate the sheets count in a loop as such. Please help
Sht_Cnt = ActiveWorkbook.Sheets.Count
For i = 1 To Sht_Cnt
If Sheets(i).Name = "Dummy" Then
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
End If
Next i