+ Reply to Thread
Results 1 to 7 of 7

Loop to SUM cells by specific range in row

  1. #1
    Registered User
    Join Date
    03-13-2009
    Location
    Malta
    MS-Off Ver
    Excel 2003
    Posts
    59

    Loop to SUM cells by specific range in row

    Hi, I need some help writing some code to calculate a sum. Here's what I am looking to do:

    In column AD (starting at AD2), I want the value to be the sum of F2 through Q2. I would like this same calculation applied down the entire AD column. So, the value of cell AD3 would be the sum of F3 through Q3, etc.

    Here is the "base" code I am trying to tweak, but have had no success. If anyone can lend me a hand, I would greatly appreciate it. Thank you in advance. Happy Holidays

    Please Login or Register  to view this content.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Loop to SUM cells by specific range in row

    I prefer an iterative method:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    03-13-2009
    Location
    Malta
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Loop to SUM cells by specific range in row

    Hey Dave,

    Thank you for responding so quickly. However, when I put the code in and ran the macro the entire AD column is still blank. Was there something I missed?

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Loop to SUM cells by specific range in row

    Give this a go.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Loop to SUM cells by specific range in row

    Sorry, that was dumb of me. Here is a correction. I was telling it to look at the bottom of an empty column, which is obviously going to be the first row...
    Assuming column "F" will have a value in each row:

    Please Login or Register  to view this content.
    Also, I see davesexcel posted another way. There are usually multiple ways to accomplish tasks, and in this case his solution is much more computationally efficient.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,526

    Re: Loop to SUM cells by specific range in row

    It sucks when the OP does not even bother to respond.

  7. #7
    Registered User
    Join Date
    03-13-2009
    Location
    Malta
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Loop to SUM cells by specific range in row

    Thanks guys for the solution! Both of the suggestions you guys listed worked perfectly! I appreciate the help greatly, Sorry for the delay in response. When I originally clicked "Submit reply" the other week, it was taking forever to load the next page so I closed the window. I assumed it went through, but ti was just taking a long time to load the next page. Sorry about that. Again, I appreciate all the help. Thanks!

+ 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