October Sale - 20% of all courses - Book Today

Reading glasses in front of computer screens

4 Tips for VBA Excellence

October 30, 2017

Tips and tricks


When we encounter a new language not to mention a programming language, it is understandable to be apprehensive about it. If you are trying to automate an Excel spreadsheet using VBA programming, it can seem especially daunting if you have never programmed before. The following tips and tricks will help you become more proficient and comfortable in your coding experience.

 

1. Using Recorder

One of the best tools you can use while creating your VBA is to use the recorder button to record a Macro. This will autogenerate the VBA code for you. While you may need to make some small changes to this code to better suit your needs, it should guide you in the right direction and approach.

The best way to facilitate code generation is to record a different macro for each step and combine it into your final programme. Which brings us to the next tip …

 

2. Following a modular approach

Try to break-up your solutions into multiple steps and tackle them separately. Create separate sub routines for tasks which are repeated.

Need to open a different file every time? – make a small sub-routine which accomplishes this task.

Modular approach will do wonders to the ease of programming. This approach also reduces coding errors and makes your programme easier to understand.

 

3. Forcing declaration of Variables

Compared to some other programming languages like C, C++, Java, etc., VBA takes a lax approach to variables, in that, it allows the use of a variable without declaring them beforehand.

This approach while easy to use at first, frequently leads to coding errors. To force yourself to declare a variable before using it in a module, use the following command at top of your module:

                  Option Explicit

 

4. Disabling Excel Alerts

Some Excel actions require a confirmation on Excel in form of alerts – e.g., deleting a sheet with some data or formatting on it pops up an Excel confirmation alert. You can disable these alerts in VBA by using the following code before the coding area where you expect the alert/s:

                  Application.DisplayAlerts = False

Later, the alerts can be re-enabled with the command:

                  Application.DisplayAlerts = True

 

Hopefully, these tips will help you along your journey to VBA programming excellence. All the very best!

 

Contact Us

What is Remote Training?

Valued by Individuals

4.8/5
Over 23577 Reviews
Excellent training course really filled in the gaps for me as a SharePoint administrator -SharePoint Site Owner Brisbane
Kristy - SharePoint Site Owner, .
Great course with very useful content. But also made me realise that Sharepoint is a massive tool with endless capabilities. -SharePoint Site Owner Brisbane
Richard - SharePoint Site Owner, .
Very good -Office365 Beginner Brisbane
Liem - Office365 Beginner, .
Great training - really good pace and so clear - enjoyed this training very much and learnt more than I knew before Thanks -Excel Customised Remote Online
Tricia - Excel Customised, .
Fantastic -Excel Customised Remote Online
Angie - Excel Customised, .
Learnt a lot thank you -Excel Customised Remote Online
Ann - Excel Customised, .
Amazing Trainer very patient and took the time to go through things thoroughly. Thank you Jason -Excel Customised Remote Online
Carly - Excel Customised, .
Very well structured course, easy to understand and follow. Highly recommended !! -Power BI Intermediate Sydney
Josep - Power BI Intermediate, .
Insightful Training. Trainer extremely helpful and took time to sort out any issues on the program. Trainer offered extra tuition if required. Trainer clear and concise in explanation. -Power BI Intermediate Sydney
Aishling - Power BI Intermediate, .
It is a good course. I learned a lot from this. Thank you -Power BI Intermediate Sydney
Eric - Power BI Intermediate, .
Very engaging, enjoyed and learned a lot. -Power BI Intermediate Sydney
Roman - Power BI Intermediate, .
Jagg teach method made the day very informative and interesting. Would have liked some notes to take away on tips and tricks. -Power BI Beginner Adelaide
Allison - Power BI Beginner, .
Very, very good. Extremely knowledgeable, very good communication, loved the hand gestures. -Power BI Beginner Adelaide
Rhett - Power BI Beginner, .
Extremely insightful and very helpful. For someone who has not had a lot of exposure to Power BI, I now feel quite confident with the basics of the program. -Power BI Beginner Adelaide
Ryan - Power BI Beginner, .
Jagg was excellent and have a good sense of humer!!. Learned a lot. Thanks Jagg. -Power BI Beginner Adelaide
Hikkaduwa - Power BI Beginner, .
Great introduction to Power BI, easy to follow along with, lots of good insight and well presented. Instruction was clear and good examples provided. -Power BI Beginner Adelaide
Linda - Power BI Beginner, .
great overview of the building of beginner power BI reports and dashboards. cant wait to build more reports -Power BI Beginner Adelaide
Louise - Power BI Beginner, .
That was very informative and well paced. Thank you -Power BI Beginner Adelaide
Hina - Power BI Beginner, .
Excellent course, Jagg was very informative and clear - thank you -Power BI Beginner Adelaide
Emma - Power BI Beginner, .
very knowledgeable -Office365 Beginner Brisbane
David - Office365 Beginner, .

Trusted by Business

south east asia microsoft training courses nexacu

Follow us