Balrajss0121
New Member
- Joined
- May 6, 2020
- Messages
- 11
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi, I am having an issue with the code below. Every time it runs and I enter a company name with an apostrophe an error is thrown that reads 'type mismatch run time error 13'. I am fairly new to vba, I have however tried to double up on the quotation marks *If Evaluate("isref('"" & ActNm & ""'!A1)") Then*. This did stop the issue but then it stops the line underneath from running and excel runs its own error for duplicated names. Any help would be appreciated on how to get rid of this. Thank you
Sub CopySheetAndRename()
Dim ActNm As String
ActNm = InputBox("Please Enter the Clients Company Name.")
If ActNm = "" Then Exit Sub
If Evaluate("isref('" & ActNm & "'!A1)") Then
MsgBox "This Company Backup Sheet already exists!"
Exit Sub
End If
Application.ScreenUpdating = False
With ActiveWorkbook
.Sheets("MASTER SHEET").Visible = True
.Sheets("MASTER SHEET").Copy , .Sheets("MASTER SHEET")
ActiveSheet.Name = ActNm
.Sheets("MASTER SHEET").Visible = False
End With
Application.ScreenUpdating = True
End Sub
Sub CopySheetAndRename()
Dim ActNm As String
ActNm = InputBox("Please Enter the Clients Company Name.")
If ActNm = "" Then Exit Sub
If Evaluate("isref('" & ActNm & "'!A1)") Then
MsgBox "This Company Backup Sheet already exists!"
Exit Sub
End If
Application.ScreenUpdating = False
With ActiveWorkbook
.Sheets("MASTER SHEET").Visible = True
.Sheets("MASTER SHEET").Copy , .Sheets("MASTER SHEET")
ActiveSheet.Name = ActNm
.Sheets("MASTER SHEET").Visible = False
End With
Application.ScreenUpdating = True
End Sub