PDA

View Full Version : Solved: What are good effective ways to error handle and bug fix a macro in ms excel?



wedd
09-21-2010, 08:03 AM
What are good effective ways to error handle and bug fix a macro in ms excel?

Thanks for the solutions...:friends:

Bob Phillips
09-21-2010, 08:39 AM
Big question. Care to be more specific?

Kenneth Hobs
09-21-2010, 09:07 AM
See:
http://vbaexpress.com/forum/showthread.php?t=24173

http://vbaexpress.com/forum/showthread.php?t=21904

wedd
09-22-2010, 01:04 AM
for example I want to create an error handling script that prevents the user from seeing an error or going into the vbe editor to read the code behind the spreadsheet or access database macros...and if there is an error within the script a user friendly message would pop up and will make the interface clean and user-friendly to the user (non-vba user). This macro will prevent technical code appearing while the user is using the spreadsheet...thanks :-)

Bob Phillips
09-22-2010, 01:35 AM
Then that is simple



Public Sub Test()

Const mpProcedure As String = "Test"

On Error GoTo Test_Error

'do your stuff

Test_Exit:
Exit Sub

Test_Error:
MsgBox "Error in procedure " & mpProcedure & vbNewLine & _
Err.Number & ": " & Err.Description
Resume Test_Exit
End Sub

wedd
09-22-2010, 03:34 AM
Thank you! :-)