+ Reply to Thread
Results 1 to 20 of 20

Accumulate then Redeem (?)

  1. #1
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Accumulate then Redeem (?)

    Hi Guys,

    I'm a fairly basic Excel user so I do apologise if this seems a silly question.

    Basically, I have a column which includes Petrol costs - I want the total of those costs to accumulate until I fill up my car with petrol, then the field that includes the accumulated total to reset to zero.

    Then the next time I add to the Petrol column I want the total petrol cost field to start totting up again, does that makes sense?

    Obviously the issue is that the total field will only need to read from the column from the first entry since the last Petrol fill up.

    I don't even know where to start with this, and really hope that my question makes sense!!

    Hope someone can help me!

    Thanks

  2. #2
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: Accumulate then Redeem (?)

    Do you want to keep the old data, from your previous full tanks?
    And how much effort are you prepared to make to redeem the data? Because I'd say just delete your data when you fill your tank...
    When I say semicolon, u say comma!

  3. #3
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    I need to keep the data. In an ideal world I'd just press a 'redeem' button and the total would reset to zero. Of course I realise that it will be difficult for the total field not to take into account the values that have already been 'redeemed'.

  4. #4
    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
    53,048

    Re: Accumulate then Redeem (?)

    Hi and welcome to the forum

    Have you started putting anything together for this yet? I understand you may not know (yet) how to do what you want, but if we can see what sort of format/layout you are working with, we can probably help with the rest?
    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

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Accumulate then Redeem (?)

    Hi,

    It would be easier if we could see the layout of your worksheet but in its absence does the attached help you with the idea.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Hi

    Yes I have a basic spreadsheet, I'll try to attach the image.

    Untitled.jpg

    I want the Petrol Money column to populate the 'Current Petrol' field with a running total, but when I use the current money to fill up I want to reset the 'Current Petrol' field to zero.

  7. #7
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Hi Richard,

    I think that might work, but not sure how to apply it to my SS... any ideas?

  8. #8
    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
    53,048

    Re: Accumulate then Redeem (?)

    Please do not upload a picture of your file...rather, upload a sample of your workbook, showing what data you are working with, a few samples of your expected outcome is (manually entered is ok) and how you arrived at that. (exclude sensitive info). Pictures are pretty much impossible to edit, and no-one wants to re-type your data for you

  9. #9
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    FDib = Apologies!

    An example SS should be attached!

    Would really appreciate it if anyone could help me find a solution to this.
    Attached Files Attached Files

  10. #10
    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
    53,048

    Re: Accumulate then Redeem (?)

    Yup, the file came through fine. However, there doesnt seem to be too much data to work with? You have 2 rows of data and the both have data in them? It sounds like you will be entering data (on a daily basis?), row by row, until you fill up again?

    If thats teh case, it would help if you could show a "typical" period of data (day, week or month), for us to work with?

    (remember, it is totally obvious to you what you have and what you want, but not so obvious to us)

  11. #11
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Hi guys,

    Updated the example spreadsheet, attached. As you can see the 'Current Petrol' field is totting up the 'Petrol Money' column - I want that field to reset to 0 when I fill up with petrol, but the 'used' data to be retained in that same column. I've populated 10 'deliveries' but the spreadsheet will go on indefinitely, so please take that into consideration.

    Hope this makes more sense to you guys now.
    Attached Files Attached Files

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Accumulate then Redeem (?)

    Hi,

    As FD has said, whilst you understand your data we (or at least I) don't. How are you defining 'when I fill up with petrol?' By that I mean where on your sheet is this event detected. Perhaps you could add an example which clearly shows a fill up situation and the 'Current Petrol' total sum.

  13. #13
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Hi Richard,

    Apologies. Basically the 'fill-up situation' will probably be different every time. In a real life example, my car needs fuel today, in my example spreadsheet there is £22.84 in the current petrol field, therefore I can put a total of £22.84 in petrol into my car. Say I do that, I then want the Current Petrol field to reset to zero. Then start totting up again from the next entry (into row 14 and so on).

    Does that make more sense? It may be that there is no formula that will do this, I realise that it may be quite complex.

    Thanks

  14. #14
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Accumulate then Redeem (?)

    Hi,

    But where do you record the fact that you've filled up? I was expecting to see this fact recorded in another column, either as a piece of text e.g. 'fill up' or perhaps a date or amount or gallons - at least some indicator.

    Failing that the only other way would be a macro connected to a button which you would click every time you wanted to reset the formula.

    i.e. For a bog standard formula to work there must be some 'marker' on the sheet itself that a formula can recognise, otherwise you will need a macro.

    Late edit: I'm attaching the workbook with a macro button included.
    Attached Files Attached Files
    Last edited by Richard Buttrey; 08-05-2013 at 07:07 AM. Reason: workbook added

  15. #15
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Hi Richard,

    A button would be ideal, unfortunately workbook you've uploaded won't work correctly but that may be because my work computer blocks the macro.

    I would add data for when I fill up and how much I fill up as well.

    Would the/a macro button know how to differentiate between petrol money that has already been 'redeemed' and that which has not?

  16. #16
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Sorry I've just realised that macros just repeat a process you've taught them - so it wouldn't work as I mentioned above...

    I'm sure there must be a way around this - perhaps I could use a forumla that would only take into account values entered after a certain date (i.e. date of last fill up)?

  17. #17
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Accumulate then Redeem (?)

    Quote Originally Posted by Tr1gg0R View Post
    Sorry I've just realised that macros just repeat a process you've taught them - so it wouldn't work as I mentioned above...

    I'm sure there must be a way around this - perhaps I could use a forumla that would only take into account values entered after a certain date (i.e. date of last fill up)?
    Hi,

    No you are incorrect. Whilst at their very simplest macros may simply play a recorded series of key strokes, most of the time macros perform much more powerful functionality than that. They can interact with the user, prompt for more information, perform logic tests and take different directions depending on the state of various conditions.

    The macro I gave you will do exactly as you have described. It will work out the next blank row and change the formula accordingly every time you click the button. You will of course need to choose to Enable Macros when prompted on opening the workbook.

    As I suggested you could use a formula but there needs to be some condition the formula can detect. You mention the date of the last fill up but your current example doesn't record any dates - or indeed any other factor which would indicate a fill up has taken place. That was exactly the point I was making in my previous post. If you want to change your workbook to record such a fact then upload another one. However since the macro version is straightforward and avoids the need to log a 'fill up' personally I'd stick with that.

  18. #18
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Richard, thank you - that's brilliant.

    I don't want to be a pain but even with macros enabled your example sheet doesn't work.

    How complicated would it be to add the button myself, could you write down how to do it here? I wouldn't expect you to do that if it takes any amount of time though, you've wasted enough time trying to help me already!

    Thanks again, I've added reputation.

  19. #19
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Accumulate then Redeem (?)

    Hi,

    What happens when you open my sheet with macros enabled and why do you think it doesn't work.

    You should first see the formula sum in G1 resulting in £22.84. The formula being =SUM(E4:E13)

    When you click the button the formula is changed to =SUM(E14:E1048576)

    Do you not see this?

    The macro in question is at what's called the Module Level and is

    Please Login or Register  to view this content.
    If you're adding it to another workbook then just copy that macro to a new Module in your workbook. ALT-F11 to go to the VBE, find your workbook name in the Project pane on the left, select the 'ThisWorkbook' item and then from the menu pick Insert Module

    Then just double click the Module1 object and in the code area on the right paste the code above. Finally on the worksheet add a button, any shape will do, right click the shape, choose 'Assign Macro' and select the 'FillUp' macro.

  20. #20
    Registered User
    Join Date
    08-04-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Accumulate then Redeem (?)

    Richard,

    Just checked this on the home PC and it works perfectly! You, my friend, are a hero!

    Thank you.

+ 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. Accumulate a value into one cell if...
    By lovethepirk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-16-2012, 11:33 AM
  2. Replies: 1
    Last Post: 06-01-2012, 06:07 PM
  3. How to accumulate time
    By michaelkwc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2008, 12:14 AM
  4. Accumulate
    By benthinkin in forum Excel General
    Replies: 1
    Last Post: 11-15-2007, 08:07 PM
  5. [SOLVED] accumulate
    By exhausted everything in forum Excel General
    Replies: 1
    Last Post: 03-14-2006, 11:30 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