+ Reply to Thread
Results 1 to 12 of 12

calculate the difference --vlookup not enough

Hybrid View

  1. #1
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    calculate the difference --vlookup not enough

    I have one excel file, more than 200 lines, structure below:

    column A B C D E F G
    company department revenue company department revenue difference
    0092 R010 1000 0190 R090 100
    0190 R020 1100 0092 R001 300
    0190 R030 2000 0092 R010 200

    we have so many rows, we need to calculate column G, which is C-F but for same company and department, how to do?

    in this case, row 1, column G should be 1000-200 (in row 3,column F)=800, for company 0092 and R010 (based on column A and B)

    any idea to be fast

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: calculate the difference --vlookup not enough

    Hi jolinchew,

    If you have the case as you shown, use below formula in G2:-

    =C2-VLOOKUP(B2,E:F,2,0)

    see attached:- calculate the diff.xlsx


    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  3. #3
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: calculate the difference --vlookup not enough

    hi, you are wrong, it should be based on both department and company ID

    your solution is based on department ID

    but different company may have same department, for example in row1 0190 company may have department ID R010.

    that's why I say vlookup not enough.

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: calculate the difference --vlookup not enough

    Okay ... no worries..

    Use the below formula which will take care of both :-

    {=C2-OFFSET($F$1,MATCH(A2&B2,D2:D4&E2:E4,0),0)}

    see attached:- calculate the diff.xlsx

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  5. #5
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: calculate the difference --vlookup not enough

    {=C2-OFFSET($F$1,MATCH(A2&B2,D2:D4&E2:E4,0),0)} is row 1 formula,

    how about row 2 formula? it seems only working for first row

  6. #6
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: calculate the difference --vlookup not enough

    also, the formula only works search downward
    given my row 3 is 190 R030 2000 92 R010 200

    if my row 2 is 190 R020 1100 190 R030 30, the formula is not working, it can't get 2000-30 by search upwards. can you have a revised version? thanks

  7. #7
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: calculate the difference --vlookup not enough

    Hi Jolinchew,

    The above formula shared by me has only the freezing issue, now corrected, see attached:
    calculate the diff.xlsx

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  8. #8
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: calculate the difference --vlookup not enough

    I put formula in another column

    =C2-OFFSET($F$1,MATCH($A2&$B2,$D$2:$D4&$E$2:$E4,0),0)

    it says #value!

    it is not working
    Attached Images Attached Images
    Last edited by jolinchew; 07-12-2012 at 11:06 PM.

  9. #9
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: calculate the difference --vlookup not enough

    press ctrl + shift + enter instead of just enter... array formula
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  10. #10
    Registered User
    Join Date
    10-06-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: calculate the difference --vlookup not enough

    I'm using apple MAC machine, it doesn't work

  11. #11
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: calculate the difference --vlookup not enough

    dilip gave you an array formula.

  12. #12
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: calculate the difference --vlookup not enough

    Thanks Vlady for explaining jolinchew..

    Hi jolinchew, let me know if you have managed to use Array formula. Thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

+ 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