Every now and again I am asked what is the best method to learn VBA. On this topic here are my thoughts on learning VBA…
- It can be a hard slog – I feel the need to warn anyone that is taking their first foray into programming that learning VBA can require a steep learning curve, depending on your background. By recording macros a user can typically make some adjustments for basic automation tasks. However, to utilize the full capabilities of VBA an understanding of basic programming and knowledge of the object model is required. This can mean a lot of work for some people and it just be worth it. Having said that, for some, it can pay dividends and it can be an interesting subject to spend time on.
- Recording Macros – For basic tasks and to aid learning, it is often useful to just record macros while you manually do the task you would like to automate. Then view the code produced by the recorder. By using the recorded macro as a starting point and modifying the code, if required, to meet your specific needs can give some insight into the object model used and the methods and arguments to use.
- Basic Programming – There is so much great info available these days that it should not take long to obtain some content that takes you through the basics of programming. What I would recommend here though is to try and find content that is project based. That is, content that takes you through building something for yourself. Doing the coding is always going to be superior to just reading about it. Making typos and other types of errors and then learning to find and correct those errors is all part of programming and is a core skill to develop.
- Exercises – Start setting yourself projects that push your current VBA knowledge. It can be a lot of work but can also be very fulfilling. For me, this is where I have found that I have learnt the most. In the same vain, it can be useful to find those sites or groups where users ask questions for others to answer. Solving issues for others can be good practice and sometimes can provide insight into the type of uses that people use VBA for.
Those are the steps that I have personally taken. In the end it seems there are no real short cuts. Getting experience under the belt was what counted for me. Luckily for me I do find programming to be an inherently challenging and interesting activity. Good luck to those who are just starting out.