+ Reply to Thread
Results 1 to 5 of 5

Excel VBA SUM function the range is misaligned

  1. #1
    Registered User
    Join Date
    08-16-2014
    Location
    Auckland. New Zealand
    MS-Off Ver
    2013
    Posts
    3

    Question Excel VBA SUM function the range is misaligned

    I am trying to do a simple summation between cell A1 and A5. I tried recording this process using the macro, however, this is what i got:

    Please Login or Register  to view this content.
    Naturally, i would think the range of the sum function would be:

    Please Login or Register  to view this content.
    as it represents cell A1 and A5. Is there any reason for this misalignment?


    Thank you!

    Miguel Valero

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Excel VBA SUM function the range is misaligned

    How well do you understand R1C1 notation? What are you expecting? If this formula is in C1 (R1C3), then it correctly refers (using relative references) to A1:A5. Were you expecting it to show absolute references (R1C1:R5C1 note the brackets are missing to indicate an absolute reference)?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    08-16-2014
    Location
    Auckland. New Zealand
    MS-Off Ver
    2013
    Posts
    3

    Re: Excel VBA SUM function the range is misaligned

    Quote Originally Posted by MrShorty View Post
    How well do you understand R1C1 notation? What are you expecting? If this formula is in C1 (R1C3), then it correctly refers (using relative references) to A1:A5. Were you expecting it to show absolute references (R1C1:R5C1 note the brackets are missing to indicate an absolute reference)?
    Thank you for the fast reply.

    Ah, I am a complete noob. I understood R1C1 as in "row 1 column 1". And you were exactly right the cell I selected was C1.

    I am intending to use absolute reference for the range inside the SUM function, is there a way to do that?

    P.S. What do you call these relative reference, and where can i read more on that?

  4. #4
    Registered User
    Join Date
    08-16-2014
    Location
    Auckland. New Zealand
    MS-Off Ver
    2013
    Posts
    3

    Re: Excel VBA SUM function the range is misaligned

    Thank you guys it worked! This is the final result:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Excel VBA SUM function the range is misaligned

    Both A1 and R1C1 notation utilize relative and absolute references. It is one of the first things I learned when learning spreadsheets (long before Excel was a gleam in MS's eye). The ability to use relative and absolute references is a big part of programming spreadsheets. This help page should give you a starting place to understand the different reference styles and how to make them relative, absolute, or even mixed.

    When you record the macro, make sure to enter the function using absolute references. The macro recorder should record the function reference as absolute.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Two misaligned cells
    By fishcad in forum Excel General
    Replies: 7
    Last Post: 04-29-2013, 09:30 AM
  2. Excel misaligned row weirdness
    By Canvasshoes in forum Excel General
    Replies: 2
    Last Post: 03-01-2012, 07:59 PM
  3. Misaligned printing
    By rev in forum Excel General
    Replies: 9
    Last Post: 03-23-2007, 06:30 AM
  4. Replies: 0
    Last Post: 08-18-2005, 12:05 PM
  5. [SOLVED] RE: Border misaligned
    By Carole Drake in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-22-2005, 09:08 PM

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