I am using the following script to unlock the sheets in a workbook:
Sub WorksheetsUnlock(sheetName1, sheetName2)
Worksheets(sheetName1).Unprotect “ABC”
Worksheets(sheetName2).Unprotect “ABC”
End Sub
I want to handle a situation where one or both sheets are not found. I am getting a pop up with the error. How to get this error in a variable?
Hy @papulepooja ,
I am expert in Excel VBA, could you share your entire project folder with me so I can take a look at your VBA Code?
This error means that something that was supposed to be found was not found
1 Like
Srini84
(Srinivas Kadamati)
June 8, 2020, 11:04am
3
@papulepooja
Hi,
Application.DisplayAlerts = False
Try that, hope it helps
Thanks
Hy @Srini84 ,
Unfortunatly that won’t work on this.
This VBA Property is to supress a message, for example, confirmation message before deleting a sheet. ok?
Hi @William_Blech_Sister ,
Thanks for you reply!
Here is a sample test code for which I am getting the same error. The VBA accepts 2 worksheets names but the excel has only one. I want to catch this error without having to deal with the message box.
TestVBA.zip (23.6 KB)
Hy @papulepooja ,
I figure out your problem
Your code takes input of two sheet names
But your file has only one
That explain your error.
I recomend you to adjust your code, for your VBA Function to take only one parameter at a time.
If you like my answer please like it and mark as solved
Regards
1 Like
Hi @William_Blech_Sister ,
I deleted the sheet to test an error in such a case where one or both the sheetnames are not found. I want to return an error in some variable.
Thanks!
1 Like
@papulepooja
Glad I could help you!!
Please dont forget to mark my answer as solution.
Thanks
Did you figure how to return the error
I use
On Error GoTo abc
x = “ss”
For x = 1 To 10
Cells(x, 1).Value = 100
Next x
Done:
Exit Function
abc:
xyz = Err.Description
it solve error message not appear anymore but can’t cath the error into UiPath even I’m using output variable it’s always null