Board Regular
Sep 18, 2012

I see there are many books available but is recording a macro the best way to learn how to program VBA....once recorded what is the next step to learning how to program VBA



Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I find macro recording to be the best way to learn quite a bit. Usually I have an idea what I want to do and the macro is just to stop me doing it 1000s of time and it is faster than me.

So I record once and then modify the code to be more general.

There are some important things that this method won't teach you.
1) When declaring a variable that you intend to use as a row index make it of type Long. There are more rows than can be referenced with an integer so it is a good habit.

2) The macro does not need to SELECT everything. The recorder will select a cell and then work on the selection. Selection slows things down. just work on the cell or range.

3) Depending on the version of excel, some things don't record. Then you need to ask questions, get a book, search for code samples.

People here are always helpful in fixing your code if you can clearly explain what you are trying to do and show you tried to write it.
Upvote 0
It also depends on how long you have been programming. I have programmed in many languages over a number of years. So it is not the programming that I have to learn but the specific objects for the language and what they can do. At the moment I am working on 3 projects all in different languages.

I am always learning new things just reading the posts on here. There are large parts of the language that I have never touched because I had no need or they seemed a weird way to do it. But in reading here I have found that some of them (Once I understood them) could have made some things easier to write.
Upvote 0
In my opinion reading a book (or taking a class) is a better way to start out than hacking recorded code. Learning the fundamentals of VBA is key and you won't get that from the macro recorder - I only really use that occasionally to save myself some typing. :)
Upvote 0
Macro recorder won't give you:

If...else..., Select Case conditional constructs.
Various loops like For Next, For each, Do While etc.

Important items if you are serious about learning VBA.

This of course not to belittle macro recorder, it can help you find syntax quickly by recording your actions.
Upvote 0
Thanks for all the replies

I have booked into a Ono-On-One 9 hour course on learning VBA.....is this a good starting point and what features should i request to learn so as to get a good understanding from the start

Upvote 0
If it's a one-on-one class then the instructor should get a pretty good feel of what you need. I'd probably make sure that you let them know how you plan to use VBA and in what environment (Finance, general, etc.), so they can tailor the class to those needs. For instance are you developing end-user solutions, or just coding to make your life easier, working with external data sources, etc.

A decent instructor should already know what you need to get you up to speed quickly, because at this point you're not likely to know what that is, so let them lead you.
Upvote 0

Forum statistics

Latest member

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back