Make your VBA macros work anywhere: Enable Relative References

Posted on November 18th, 2008 in Learn Excel - 1 comment

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

| More
Subscribe for PHD Email updates and get a free excel e-book with 95 tips & tricks


Trackbacks & Pingbacks

Comments

RSS feed for comments on this post. TrackBack URI

Leave a comment

   Name (required)

   E-mail (required, never displayed)

   URL


If you have a question, please ask in the forums

Recommended Excel, Charting, VBA books