+ Reply to Thread
Results 1 to 7 of 7

SUMIF and LOOP till the last row

  1. #1
    Registered User
    Join Date
    06-26-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    74

    SUMIF and LOOP till the last row

    Hi

    How would one go about creating a macro that would sum values in column G based on a condition in F ( a "SUMIF" basically) until the end of the range?

    The condition would be so that the first blank cell in Column G (starting from column G9 ie Range("G9").End(xlDown).Offset(1,0) would contain the sum of everything above up until the word "Total" (or even the string of 5 characters from the left say "Total") appear in Column F - (the word Total appears a few times in column F, so it should detect the first applicable one)

    The idea would be to have this repeated / looped until the end of the data range

    Attached is an example and I hope what I have written makes sense

    As for the worksheets:

    "Final" is what it should look like (Blue Cells represent manual calculations)

    "Working" Sheet is where I have it up to now

    The sheet "Original" has a button that recreates everything up until where "Working" Sheet is

    Sheet ("Tenant History Schedule") is scrap sheet

    Thanks guys
    Attached Files Attached Files
    Last edited by georgeanaprop; 02-01-2010 at 02:26 AM.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: SUMIF and LOOP till the last row

    Onemore question
    Do you want to Sum up everything except for Totals and re-color them in blue color as well?
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    06-26-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: SUMIF and LOOP till the last row

    doesn't need to be blue, that was just there to highlight where the calculation fits

    It should sum everything up to and including the value in Column G where the word "Total" appears in Column F (ie where the first 5 strings from the left are total) last if working from the bottom up

    If you look at G47 in the final sheet, it sums everthing up from G46 to G30 (F30 is the word total)

    Then the next cell that requires a calculation is G49, that sums everything from G48 up until where it recognises the first time "total" appears above it in column F thus it sums G48 to G47 (F47 has the word Total)

    Similarly, G62 adds everything up from G61 to G58 (where F58 has the first 5 characters as Total)

    Does that help?
    Last edited by georgeanaprop; 01-29-2010 at 03:06 AM.

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: SUMIF and LOOP till the last row

    hi and sorry for very! late response. I had to go yesterday, and couldn't post reply. Below code is what I came up with. Hope it will help you


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by contaminated; 01-29-2010 at 02:58 PM.

  5. #5
    Registered User
    Join Date
    09-17-2009
    Location
    Russia, St. Petersburgh
    MS-Off Ver
    Excel 2003/2007
    Posts
    62

    Re: SUMIF and LOOP till the last row

    Hi contaminated
    Can u explain this code.... pls....
    I need almost same thing....

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: SUMIF and LOOP till the last row

    bambino32, you have been a member long enough to know that:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

  7. #7
    Registered User
    Join Date
    06-26-2009
    Location
    South Africa
    MS-Off Ver
    Excel 2003
    Posts
    74

    Re: SUMIF and LOOP till the last row

    Thanks guys. I had also come up with a solution and they all seem to help

    Thank You!

+ 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