Page 14 of 24PREVNEXT

Get in the loop with Excel macros

Reference style R1C1 correlates to Cells property

Columns represented as numbers instead of letters.

Loop macros use two different methods to bring a cell's data into their code. One is called the Cells property, and the other is called the Range property. In VBA, it is usually easier and more convenient to use the Cells property, because it is easier to change the values described by that property. The Range property identifies rows and columns using the worksheet numbers and letters, while the Cells property uses numbers for both rows and columns. Adding +1 to those numbers moves a loop macro conveniently from row to row and from column to column, but there is no convenient way to move from one letter to the next in the code.

Tip     You can see column numbers instead of column letters in your spreadsheet if you prefer. On the Tools menu, click Options, and then select the General tab. Check the "R1C1 reference style" box. If you want to change again later, clear that check box.

Page 14 of 24PREVNEXT