I am trying to execute a macro by passing a string parameter. I want to delete the Sheet by providing the sheet name as parameter in the Macro. It is getting executed but it is not performing the required action. Used a message box to check whether the parameter is getting passed properly. The message box is displaying the correct value. Can anyone help me out in this.
hi @PJain
you can use the below code and let us know
Sub SheetKiller()
Dim s As Worksheet, t As String
Dim i As Long, K As Long
K = Sheets.Count
For i = K To 1 Step -1
t = Sheets(i).Name
If t = "ID Sheet" Or t = "Summary" Then
Application.DisplayAlerts = False
Sheets(i).Delete
Application.DisplayAlerts = True
End If
Next i