+ Reply to Thread
Results 1 to 10 of 10

how to add cost codes and add running totals to a cell

  1. #1
    Registered User
    Join Date
    09-29-2016
    Location
    Cambridge, Ontario
    MS-Off Ver
    2007
    Posts
    5

    how to add cost codes and add running totals to a cell

    Alright, rookie here, so I want to make a formula that says: if(B1=1, then put the number in A1 in D1, (if A2=2, then put the number in A1 in D2, (if A2=3 then...) and so on until A2=5

    I hope that makes sense. Thank you in advance for any help.

    Let's try this another way.

    I have $ values from receipts in A1 and I want to cost code them in B1 (with the numbers 1-5) then send the number in A1 to say D1,2,3,4, or 5 based on the cost code. I want to make a pattern in columns A and B to add $ values and cost codes and if possible make the numbers go to D1,2,3,4 and 5 as running totals (i.e. keep adding everything that's cost coded "1" to cell D1).
    Last edited by kwguy; 09-29-2016 at 02:49 PM.

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: I think it's an if formula I need?

    you could
    in D1 put

    =if(b1=1, a1, "")

    are we using A2 or B1 or both ?

    in d2 put
    =if(b1=2, a2, "")

    in d3 put
    =if(b1=3, a3, "")

    this could be made to copy down using row()
    just not sure now as i'm confused what you want now - reading through the question
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    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,939

    Re: I think it's an if formula I need?

    Hi, welcome to the forum

    your request is a bit confusing...
    if(B1=1, then put the number in A1 in D1
    if A2=2, then put the number in A1 in D2,
    if A2=3 then....
    and so on until A2=5
    is B1 a typo?
    Last edited by FDibbins; 09-29-2016 at 02:55 PM.
    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

  4. #4
    Registered User
    Join Date
    09-29-2016
    Location
    Cambridge, Ontario
    MS-Off Ver
    2007
    Posts
    5

    Re: I think it's an if formula I need?

    Thanks etaf, your solution does work but now I also want to also make D1 a running total of values from column A (i.e. when I enter a number in A2 and cost code it 1 in B2 I want it to add to the number already in D1)

    Sorry, I made an edit to my first post that will hopefully help clarify.
    Last edited by kwguy; 09-29-2016 at 03:02 PM.

  5. #5
    Registered User
    Join Date
    09-29-2016
    Location
    Cambridge, Ontario
    MS-Off Ver
    2007
    Posts
    5

    Re: I think it's an if formula I need?

    If I had to tell D1 what to do using plain English this is what I'd say "if 1 is entered into any cell in column B then take the number in the cell beside it (column A) and add the numbers together here."

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: how to add cost codes and add running totals to a cell

    can you mock up an example

    Please upload a small clean sample of your data / workbook (not a picture) to the forum, Make sure you have removed any private information, remember this is a public forum and so available to anyone
    We would like to see an example of your data and also a manual mock up of the expected results you want to achieve.

    To attach a file to your post,
    click "Go advanced" (next to quick post),
    scroll down until you see "manage Attachments",
    click that and select "Choose File" (top Left corner).
    Find your file, click "Open" click "upload" click 'close windows" Top Right. click "Submit Reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.

  7. #7
    Registered User
    Join Date
    09-29-2016
    Location
    Cambridge, Ontario
    MS-Off Ver
    2007
    Posts
    5

    Re: how to add cost codes and add running totals to a cell

    Here's the actual sheet I'm trying to work with (no personal data). Sorry for the confusion. Hope this works.
    Attached Files Attached Files

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: how to add cost codes and add running totals to a cell

    use SUMIF()
    =SUMIFS($A$7:$A$11,$C$7:$C$11,1)
    =SUMIFS($A$7:$A$11,$C$7:$C$11,2)
    =SUMIFS($A$7:$A$11,$C$7:$C$11,3)
    =SUMIFS($A$7:$A$11,$C$7:$C$11,4)
    =SUMIFS($A$7:$A$11,$C$7:$C$11,5)
    see attached
    i have hardcoded 1,2,3,4,5 - but we could take those from the description
    =SUMIFS($A$7:$A$11,$C$7:$C$11,LEFT(E7,1))
    and copy down

    sorry I used sumifs() - still works
    so does SUMIF()
    =SUMIF($C$7:$C$30,LEFT(E7,1),$A$7:$A$30)
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-29-2016
    Location
    Cambridge, Ontario
    MS-Off Ver
    2007
    Posts
    5

    Re: how to add cost codes and add running totals to a cell

    You rock, thank you!!! It's doing exactly what I wanted it to. I would have never figured that out on my own, this site is an awesome resource, I'll be back if needed.

  10. #10
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: how to add cost codes and add running totals to a cell

    you are welcome

+ 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. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  2. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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