How to handle errors in VBA?

 1) Overflow error (Run-time error 6)

This error occurs mainly because of 2 reasons:

a) When we assign a large value to a small memory allocated variable. Like assigning a long value to an int variable.

b) When we divide zero (0) by (0) Ex: a/b = 0/0. The a and b both holds 0.

2) Worksheetfunction.find method not found (Run-time error)

Sometimes when we use "On error goto X" could also lead to an error. In that case, we may check the values whether they hold values greater than 0 or not using if-else logic, avoiding "On error goto X".



Comments

Popular posts from this blog

Power Automate - Automatically fetch data from Power BI in to Excel and Send the copy of the Excel file via Email

Separate Text (Characters) & Numbers from Alpha Numeric String Using Formula and Macro (VBA)

File System Object