+ Reply to Thread
Results 1 to 11 of 11

Subtract value if value matches that of another cell

  1. #1
    Registered User
    Join Date
    10-19-2022
    Location
    KY
    MS-Off Ver
    Office 360
    Posts
    3

    Subtract value if value matches that of another cell

    Hello all, and thanks ahead of time for any help you are able to provide. New to what I would consider more complicated Excel formulas, so I'll try not to confuse with my request!

    In the attachment, I'd like to populate column N on the September 2022 sheet with something like =M2-'August 2022'!M2 but only if the value in column B matches. The problem is, I need to do this month over month and the values in column B will not always abe in the same order. I believe it will need to match via VLOOKUP?? I hope this makes sense, please ask clarifying questions as needed.

    Thank you!
    Attached Files Attached Files

  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,792

    Re: Subtract value if value matches that of another cell

    just checking

    you want to subtract the August value in N from the September value in N only for matching Keys

    What if they do not match at all - what do you want in the cell

    the values in N are not numbers but text
    so i have just done a formula to remove the $ - and put that into N

    Now i have a formula in O
    so
    =N2-INDEX('August 2022'!N:N,MATCH('September 2022'!B2,'August 2022'!B:B,0))
    will subtract

    If there is no key match you get N/A error - which with an IFERROR can be fixed

    There maybe a way to automate the months info
    so it goes to the correct sheet based on the month - but need to see if you need that

    anyway heres a start
    Attached Files Attached Files
    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
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Subtract value if value matches that of another cell

    this should work for you in the sept 2022 tab in cell N2 dragged down... =IFERROR(M2-VLOOKUP(B2,'August 2022'!$B$2:$M$400,12,FALSE),"")
    I believe you also have access to xlookup which might work as well.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Subtract value if value matches that of another cell

    What Wayne noted about text and not numbers is interesting, my formula returned a result as you can see in the attached.
    Attached Files Attached Files

  5. #5
    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,792

    Re: Subtract value if value matches that of another cell

    maybe its something on my excel - but its changing the value to text $12345
    if i then put in N
    M2-1 - i get a value error

    the OP has the formula and so if its is a number then they will both work - if not then the text needs to be changed to a number

    heres your file back
    still gives an error

    as i say maybe its my excel converting
    Attached Files Attached Files

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,504

    Re: Subtract value if value matches that of another cell

    Wayne, it is interesting because you are right excel isn't recognizing them as numbers as =isnumber(M2) in the august tab returns FALSE and that is on mine yet the formula is working.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,628

    Re: Subtract value if value matches that of another cell

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Registered User
    Join Date
    10-19-2022
    Location
    KY
    MS-Off Ver
    Office 360
    Posts
    3

    Re: Subtract value if value matches that of another cell

    Thank you all so much! Will definitely report back results when back at desk.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,628

    Re: Subtract value if value matches that of another cell

    Looks like manually entered dollar signs rather than numeric values with appropriate formatting.

  10. #10
    Registered User
    Join Date
    10-19-2022
    Location
    KY
    MS-Off Ver
    Office 360
    Posts
    3

    Re: Subtract value if value matches that of another cell

    Quote Originally Posted by etaf View Post
    just checking

    you want to subtract the August value in N from the September value in N only for matching Keys

    What if they do not match at all - what do you want in the cell

    the values in N are not numbers but text
    so i have just done a formula to remove the $ - and put that into N

    Now i have a formula in O
    so
    =N2-INDEX('August 2022'!N:N,MATCH('September 2022'!B2,'August 2022'!B:B,0))
    will subtract

    If there is no key match you get N/A error - which with an IFERROR can be fixed

    There maybe a way to automate the months info
    so it goes to the correct sheet based on the month - but need to see if you need that

    anyway heres a start
    You guys are awesome, thanks for all the help. I ended up using this version with an IFERROR after converting M to a number and removing the dollar signs. The formula ended up being
    =IFERROR(M7-INDEX('August 2022'!M:M,MATCH('September 2022'!B7,'August 2022'!B:B,0)),"not found").

    I'm curious about automating the months. It would also be subtracting column M from the previous month, which would be on the sheet prior as well.

    Thanks again.

  11. #11
    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,792

    Re: Subtract value if value matches that of another cell

    I'm curious about automating the months.
    can you give examples of this

    =IFERROR(M7-INDEX('August 2022'!M:M,MATCH('September 2022'!B7,'August 2022'!B:B,0)),"not found").

    you maybe able to use an indirect() function to do some automated dates
    as you add more sheets

+ 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: 3
    Last Post: 09-09-2021, 05:08 PM
  2. Subtract until 0 then move to next cell to subtract until 0
    By manateee in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-15-2020, 03:32 AM
  3. [SOLVED] take the sum of cell D40, subtract it with cell D39, then spread evenly across cell range
    By JRP Excel Guy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-23-2019, 01:28 PM
  4. [SOLVED] If date matches and room matches, return room info in to cell
    By HonorBray in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-12-2018, 12:09 PM
  5. [SOLVED] If Account column value matches, add/subtract to a cell value
    By shivers in forum Excel General
    Replies: 4
    Last Post: 07-19-2017, 12:42 PM
  6. Replies: 4
    Last Post: 03-14-2014, 09:54 AM
  7. Replies: 1
    Last Post: 01-27-2012, 11:25 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