+ Reply to Thread
Results 1 to 4 of 4

using relative reference in macros

  1. #1
    Registered User
    Join Date
    03-13-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2010
    Posts
    27

    Question using relative reference in macros

    hi all,

    a user i'm assisting wants to calculate totals by recording a macro that sums all the rows in a column using relative cell references. this is because the user runs a report that pulls in data that varies. one week the report may contain 40 rows that need to be totaled, and the next week there may be 60 rows that need to be totaled.

    here's what i did:
    • place cursor in cell where i want total to appear
    • go to VIEW menu, MACROS tab, and click USE RELATIVE REFERENCES
    • click RECORD MACRO
    • enter name, description, assign shortcut key
    • go to FORMULAS menu and click AUTOSUM
    • press RETURN

    when i test the macro out on columns containing the same amount of rows, it works fine. but when i run the macro on a column with more rows, it only totals the amount of rows contained in the original macro. see attached.

    Notes:
    • tab t1_2010 contains fewer rows than tab t2_2010.
    • i recorded a macro on tab t1_2010 called TOTALS

    please help.

    thanks for reading.

    best,

    ian
    Attached Files Attached Files
    Last edited by ilundy77; 02-04-2010 at 03:29 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: using relative reference in macros

    How about this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    03-13-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: using relative reference in macros

    works beautifully! thanks so much.


    best,

    ian

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: using relative reference in macros

    Just for chuckles how about this...it will add all the totals for you all at once;
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1