UrbanPro
true

Learn Business Analysis Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Eight Bug Reduction Tips: VBA

G
Gaurav C
20/11/2017 0 0

You cannot completely eliminate bugs in your programs, but there are a few tips that will help you keep them to a minimum:

i. Use an Option Explicit at the beginning of your module: Doing so will require that you define the data type for every variable that you use. It’s a bit more work, but you’ll avoid the common error of misspelling a variable name.. And there’s a nice side benefit: Your routines will often run faster.

ii. Format your code with indentation: Using indentation to delineate code segments is quite helpful. If you have several nested For Next loops, for example, consistent indentation will make it much easier to keep track of them all.

iii. Be careful with On Error Resume Next: This statement causes Excel to ignore any errors and continue. In some cases, using this statement will cause Excel to ignore errors that shouldn’t be ignored. Your may have bugs and not even realize it.

iv. Use lots of comments: Nothing is more frustrating than revisiting code that you wrote six months ago, and not having a clue as to how it works. Adding a few comments to describe your logic can save you lots of time down the road.

v. Keep your subroutines and functions simple: Writing your code in smaller modules, each of which has a single, well-defined purpose, makes it much easier to debug them.

vi. Use the macro recorder to help you identify properties and methods: If I can’t remember the name or syntax of a property or method, it’s often quicker to simply record a macro and look at the recorded code.

vii. Consider a different approach: If you’re having trouble getting a particular routine to work correctly, you might want to scrap the idea and try something completely different. In most cases, Excel offers several alternative methods of accomplishing the same thing.

viii. Understand Excel’s debugger: Although it can be a bit daunting at first, you’ll find that Excel’s debugger is an excellent tool. Invest some time and get to know it.

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

How to install Analysis ToolPak in Excel
The Analysis ToolPak is an Excel add-in program that provides data analysis tools for financial, statistical and engineering data analysis. To load the Analysis ToolPak add-in, execute the following steps. 1....

VBA Tip: Print Random Numbers In A Selected Range
Let’s say you want to print some random numbers in a selected range then you can use below Macro. Sub Print_Randomnumbers() Dim myrng As Range For Each myrng In Selection myrng.Value = Application.WorksheetFunction.Int(Rnd...

Basics of K means classification- An unsupervised learning algorithm
K-means is one of the simplest unsupervised learning algorithms that solve the well-known clustering problem. The procedure follows a simple and easy way to classify a given data set with n objects through...

Rand() Function
Purpose: Get a random number between 0 and 1. Return Value: Any decimal number between 0 and 1. Syntax: =RAND() Usage: RAND() function will returns a number between 0 and 1. For example, = RAND()...

How to work fast while working on MS Excel?
Many people struggle to find out the way on how they can work faster while working on MS Excel/Access or VBA. let me share the tip for that. If you are new or working since long time on Excel/Access...
X

Looking for Business Analysis Training Classes?

The best tutors for Business Analysis Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Business Analysis Training with the Best Tutors

The best Tutors for Business Analysis Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more