+ Reply to Thread
Results 1 to 5 of 5

Summing certain rows in a for loop

  1. #1
    Registered User
    Join Date
    07-25-2011
    Location
    Virginia, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Summing certain rows in a for loop

    Hi,

    I have code that loops through several columns and I am trying to add a few rows. For example, I want cell B13 to sum B14-B16; C13 to sum C14-C16, and so on. The code below sums everything. It adds B14, B15, B16, C14, C15, C16 and repeats the same number in row 13. In theory I should have different numbers is B13 and C13. Please help!!

    Please Login or Register  to view this content.
    Last edited by miam; 07-25-2011 at 02:37 AM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Summing certain rows in a for loop

    Hi and welcome to the forum.

    No need for a loop:
    Please Login or Register  to view this content.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Registered User
    Join Date
    07-25-2011
    Location
    Virginia, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Summing certain rows in a for loop

    Thank you Colin!

  4. #4
    Registered User
    Join Date
    07-25-2011
    Location
    Virginia, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Summing certain rows in a for loop

    Hi Colin, may I ask a follow up question. The code you suggested worked beautifully for my intended purpose so thanks again. I need to repeat the equation again, but this time the variables I am using are in sequential cells, but the output skips a cell. When I use the code below it skips reading the input because the output skips a cell as well.

    Please Login or Register  to view this content.
    For example, I want to display the results in C57, E57, G57, etc. but the data I'm pulling from is in column B,C,D. I want C57 to use information found in column B; E57 to use info in column C, and so on. Can you please help?

  5. #5
    Registered User
    Join Date
    07-25-2011
    Location
    Virginia, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Summing certain rows in a for loop

    Lastly, if its not too much trouble. Could you help me with the syntax for a related If statement.

    Please Login or Register  to view this content.
    Last question, I promise. I truly appreciate your help!!

+ 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