
Our code, if written in English instead of Excel VBA, would say this: If the current reference style is A1, change it to R1C1, otherwise (if it’s not A1), change it to A1. To do that, we’ll add bit of If…Then code, similar to an IF formula on the worksheet. If it’s currently A1, our macro will change it to R1C1, and vice versa. We’d like our macro to toggle the setting.

The first line sets it to R1C1 and the second line sets it to A1 style. In the recorded Excel VBA code, you can see the two lines that change the reference style.

#VISUAL BASIC FOR EXCEL USING R1C1 CODE#
To see the Excel VBA code that changes the setting, we can use the Excel Macro Recorder. Step 1: Record a Macro to Switch Column Headings to Numbers We’ll create a macro that will let us quickly switch from A1 to R1C1, or from R1C1 to A1. That setting is pretty well hidden, and it’s a bit of a pain to switch on and off.
#VISUAL BASIC FOR EXCEL USING R1C1 HOW TO#
We’ve talked about the Excel Column Headings before, and seen how to change the Reference Style setting from R1C1 (Numbers) to A1 (Letters).

It’s Friday, and your brain is almost full, but let’s try to cram a little bit of Excel VBA in there before the weekend.
