Hi,
How can I stop opening the same worksheet inside the workbook even though I put error-handling features? Can you help me?
kim
Hi,
How can I stop opening the same worksheet inside the workbook even though I put error-handling features? Can you help me?
kim
Re: how to stop
Could you please provide more detail, and the code you are using?
Re: how to stop
Read the Forum Rules then edit your post's Title.
Re: how to stop
Hi Ben,
The problem in my workbook that every time I try to put an error-handling features to stop the same worksheet from opening, it still opens the worksheet but it name differently but the information contain in the worksheet is the same. So I want to stop it from opening the worksheet. Here's the code I was using:
On Error Resume Next
Set wks = Worksheets("STPOA.xlsx")
If wks Is Nothing Then
Workbooks(WK1).Worksheets(Count2).Name = x & ".STPOA"
Else
MsgBox "The 'STPOA.xlsx' worksheet is already in use and cannot be open.", vbCritical
End If
On Error GoTo 0
Display More
Kim
Re: Stopping opening same worksheet
There's nothing in that code to open a Worksheet.
Where is the actual code?
Remove the On Error
Re: Stopping opening same worksheet
Hi roy,
That code there always be highlighted by the run-time error. So here is the code:
'open target workbook
On Error Resume Next
Workbooks.Open Application.DefaultFilePath & "\" & find1 & "\" & WK2
'locate worksheet
If Err.Number <> 0 Then
MsgBox "Invalid input"
Unload Me
uf4.Show 'False
End If
On Error GoTo 0
kim
Don’t have an account yet? Register yourself now and be a part of our community!