fbpx

Make your VBA macros work anywhere: Enable Relative References

Share

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Do you know that while recording macros in excel you can use the relative reference based recording so that you can use your macro anywhere and the references would be adjusted automatically?

Yes!

I have learned this yesterday and I thought it is pretty cool.

Here is how you can make your macro VBA code references relative:

When you select “record new macro” from menu > tools > macros, excel shows a very little macro recording toolbar with a start button and another button. That another button is the one we use to toggle between relative and absolute references in macro code.

See this:

vba-macro-recorder-relative-feature

And the code generated by relative and absolute references is shown here:

vba-macro-code-relative-vs-absolute-references

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Excel School made me great at work.
5/5

– Brenda

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

two level data validation drop down excel

Two-level Data Validation [Excel Trick]

Ever wanted to create a two-level data validation list? You can use this simple trick to make two-level or cascading drop-down validation lists in Excel. You need some data, a pivot table and simple IF formulas to get this. Read on to understand the process and create your own two-level drop down lists in Excel.

2 Responses to “Make your VBA macros work anywhere: Enable Relative References”

  1. [...] Chandoo isn’t adverse to recommending VBA solutions either. [...]

  2. CLAUDE BARTAUD says:

    Thank you for the informations you give.
    I am using Excel 2003. The button absolute/relative is no more operating. Once I have set relative reference macro code I can't go back to the default option for all my Excel files.
    I'm looking either a method to reinitialize Excel or a VBA instruction to force the absolute option.
    Sincerely.

Leave a Reply