+ Reply to Thread
Results 1 to 11 of 11

Suggestions for an auto-sum problem (that's probably quite simple!)

  1. #1
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Suggestions for an auto-sum problem (that's probably quite simple!)

    Hello there. I'm making a simple worksheet for a friends gliding club. It shows how long they've flown for on a list of sequential days and also lists against each day, the number of lost events (ie they couldn't fly for some reason) in two columns, weather and mechanical. (See attached image).

    I'm trying to think of a way that I can automatically get the worksheet to calculate 'time since last lost event". Ideally the worksheet would sum the duration listed against each day starting the day after a lost event has been recorded.

    I've made it sound quite complicated but I'm sure if you are quite experienced on Excel/VB, you'll probably scoff at how easy this is.

    Any help is appreciated, sorry I could only upload an image of the worksheet, I can email a copy of it helps.

    John
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    Oops think my image cut a bit of my text box off, in the example shown, the time since last lost event would be 90 ie 40 + 30 + 20.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    It would help if you could post a small file with sample data and expected results.

  4. #4
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    Ah ok, that's what I was trying to do but my iPhone wouldn't allow me to attach excel files, just pictures. If it helps, the attached image is of my sample data and the expected result is 90.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    try ...

    =SUMPRODUCT((OFFSET($B$7,MAX(MATCH(999,$C$7:C1000,1),MATCH(999,$D$7:D1000,1)),0,100,1)))

    Ranges based on your sample of starting in row 7

    The MATCH formula find the row with the last "lost events" in either C or D

  6. #6
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    You my friend are a genius. It works perfectly, I'm not even going to pretend to understand how it works!

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    I did a further test and you will get an error condition if there is only 1 in either C or D column. Is this likely to be the case?

    Let me know as it means testing each column individually for an error condition.

    As for how it works: the MATCH formula find the row were the last 1 in columns C & D is placed and the MAX determines whether its is C or D.

    The OFFSET uses the row found to determine where to start adding from (offset from B7).

    SUMPRODUCT simply sums the numbers (the 100 allows for 100 rows of data which you can change).)

  8. #8
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    I've worked through it as I tried to ensure I'm not just blindly pasting your formula in so at least I learn something from it (I love Excel - I'm just very mediocre at it!). I found that to make it work in its current form, I had to insert a couple of dummy values and increase the range looked at accordingly (see attached Excel file - filed yellow where I tweaked).
    Attached Files Attached Files

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    Try using a helper column, which will give you a running total...
    E
    F
    G
    H
    I
    5
    Day Time Weather A4
    6
    1
    1
    7
    Mon
    20
    20
    8
    Tue
    20
    40
    9
    Wed
    40
    2
    0
    10
    Thu
    20
    1
    0
    11
    Fri
    30
    30

    I7=IF(SUM(G7:H7)=0,I6+F7,0)
    copied down
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    Much better than my solution! And fits with the " that's probably quite simple! " comment. Being smart not clever!

    For completeness this removes the error conditions:

    =SUMPRODUCT((OFFSET($F$7,MAX(IFERROR(MATCH(999,$G$7:$G$11,1),0),IFERROR(MATCH(999,$H$7:$H$11,1),0),0),0,100)))

    But I would go with helper column suggestion.
    Last edited by JohnTopley; 08-09-2015 at 08:53 AM.

  11. #11
    Registered User
    Join Date
    10-27-2014
    Location
    UK
    MS-Off Ver
    2003
    Posts
    14

    Re: Suggestions for an auto-sum problem (that's probably quite simple!)

    Well thank you everyone! I demonstrated my new feature to my friend and he decided it wasn't a metric he was bothered about!!!

+ 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. [SOLVED] Please scrutinize this simple working function and give your suggestions
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2015, 01:00 PM
  2. Excel Drop Down list with Search Suggestions against Auto Generate Serial Number
    By silambarasan.J in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-22-2015, 04:27 AM
  3. Simple Auto Sort
    By TheWelshOne in forum Tips and Tutorials
    Replies: 0
    Last Post: 07-04-2014, 02:37 PM
  4. Replies: 1
    Last Post: 12-04-2012, 04:40 AM
  5. My problem is simple - no - it's me that's simple...
    By Glenn Kennedy in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-08-2012, 02:20 PM
  6. Auto select yes line required in macro code - tried suggestions found on net to no avail
    By Andrew E Smith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2012, 09:25 AM
  7. Simple Auto-save...
    By Push Latency in forum Excel General
    Replies: 1
    Last Post: 09-16-2009, 11:42 AM

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