Hi guys, I am writing a code to check if a user input sheet name exist in the workbook. Here is what I done:
However I am getting"ByRef argument type mismatch" at the if statement. Any idea what when wrong?
Code:
Function SheetExists(SheetName As String)
On Error GoTo no:
WorksheetName = Worksheets(SheetName).Name
SheetExists = True
Exit Function
no:
SheetExists = False
End Function
Dim ImportingSheet As String
ImportingSheet = InputBox("Type in the sheet you want to import from (Case sensitive)", "Type Sheet Name", "Email 2018")
If SheetExists(ImportingSheet) Then
MsgBox "The sheet exist"
Else
MsgBox "The sheet does not exist. Check again"
End
End If
However I am getting"ByRef argument type mismatch" at the if statement. Any idea what when wrong?