How to Learn Excel Macros

How can I learn macros in Excel?Range("A2").Select
I have been asked this question many times byThis code can be simplified, the underlying ideas being:
friends and colleagues. I don't think I have a perfect1. There is no need to select the cell
answer for this, this is what I think.2. There is redundant code that can be removed
Firstly, it is seldom good idea to pick up a book onThe above code can be written into 2 lines:
Excel programming and start reading it from cover toRange("A1").Interior.ColorIndex = 6
cover. I haven't seen this work so far, not only forRange("A1") = 34
Excel VBA but for computer applications in general.The code is not only smaller but also more efficient: it
It is better to learn when there is a specific task atdoes only the required tasks and nothing more.
hand. Excel's macro recorder is a great way to begin:Learning to code this way takes some practice.
start the recorder, do the steps manually, and thenExcel's VBA help is a great resource. To learn about
examine the code.the use of a specific keyword, type the word, place
The next step is to learn to modify and optimize thethe cursor over it and press the F1 key. Sometimes it
code generated from the macro recorder. Forhelps to just look at the example in the help first
example, if the step needed is to change thethan read the details.
background colour of the cell A1 to yellow and put inOnce mastery of basic code is achieved, it is the
the number 34 into it, the macro recorder generatesright time to pick up a book on VBA coding and
the following code:explore greater depths and possibilities.
Range("A1").SelectVBA code is certainly not difficult to learn, but writing
With Selection.Interiorefficient code takes some practice. Once you know
.ColorIndex = 6VBA, it is fun too ! I have had great satisfaction
.Pattern = xlSolidplaying with code and watching it do exactly what I
End Withwant as I sipped coffee!
ActiveCell.FormulaR1C1 = "34"