Hi All,
Help required to create macro to delete all sheets excepts on the one sheet which is mentioned via input box. I have tried with the below macro but getting the error message "Run-Time error '438"
Help required to create macro to delete all sheets excepts on the one sheet which is mentioned via input box. I have tried with the below macro but getting the error message "Run-Time error '438"
Code:
Sub retain()
Dim todelete As Worksheet
Dim Filetodelete As String
Filetodelete = InputBox("Enter file name")
For Each todelete In Application.ActiveWorkbook.Worksheets
If todelete <> "filetodelete.value" Then
todelete.Delete
End If
Next
End Sub