+ Reply to Thread
Results 1 to 7 of 7

Trying to match data in different columns

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Trying to match data in different columns

    I have data on exports and imports for 60 or so countries. My data looks like this

    Argentina Australia 123456 Argentina Australia 123456
    Argentina Belgium 564789 Argentina Austria 123146
    Argentina Brazil 879455 Argentina Belgium 1231458
    Argentina Canada 456789 Argentina Brazil 2312365
    Australia Australia 123456 Argentina Bulgaria 123456
    Australia Belgium 564789 Argentina Canada 123146
    Australia Brazil 879455 Australia Argentina 1231458
    Australia Canada 456789 Australia Austria 2312365

    What I need to do is subtract the first column of numbers from the second, but only when the first and second columns match the fourth and fifth. Unfortunately, because the columns 4-6 are longer than 1-3, I need to get Excel to look for the match within an array. What I am doing now is using vlookup to get excel to search, for example, for "Australia" in the second column and then return the value in the third column. However, at the moment, I need to manually specify the table array (because the word australia will reappear about 60 times). Is there a way to get excel to automatically do this for me?

    Many thanks for any help.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Trying to match data in different columns

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

  3. #3
    Registered User
    Join Date
    08-19-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Trying to match data in different columns

    Right, sorry. Don't know how to download then re-upload the previous attachment, so here is a subset of my data.

    Basically I have trade pairs - figures for trade between two countries. I am trying to get non-fuel trade, which involves deleting trade in fuels from total trade. The columns shaded in green show imports of fuel by the country in column A (reporter) from the one in column B (partner).

    The cells shaded in pink show total trade imports (by reporter, from partner). Because a country imports fuels from fewer countries than it imports all possible goods, the entries for imports of fuel for a country are smaller than the entries for all goods (so the entries for Argentina in column A are 39 cells vertically, whereas in column E there are 65 cells).

    I am trying to subtract the figure for imports of fuel into Argentina from Australia from the total imports figure for the same two countries.

    At the moment, as in the attachment, I use vlookup((F2,B$2:C$40,2,FALSE), so I am looking for the word Australia in B2:C40 and returning the corresponding number in column B. However, this means going down the colum (over 4000 cells long) and changing B2:C40 every time the country in column A changes.

    I am looking for a way to get the same data, but for excel to do it automatically. Basically this means, for a given country in Column A and column E (must be the same country), Excel looking in column F for the same country in column B and returning the number in column c.

    Hope this is clear. Thanks for the help.
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Trying to match data in different columns

    A few approaches in truth... one might be to do the following:

    D2: =A2&":"&B2
    copied down for all rows of data in A:B

    Your formula then becomes a quick SUMIF

    H2: =SUMIF(D:D,E2&":"&F2,C:C)
    copied down for all rows

    The SUMIF approach will also handle possibility of pair (E:F) not existing in A:B ... ie 0 will be returned by default.

  5. #5
    Registered User
    Join Date
    08-19-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Trying to match data in different columns

    You, sir, are a genius. You've saved me a great deal of time and hassle. Thanks.

  6. #6
    Registered User
    Join Date
    10-06-2009
    Location
    Kenya
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Trying to match data in different columns

    hi good people,
    My situation is rather simple but i am unable to hack it, the situation is, in the process of reconciling other pending payables for the purposes of audit schedules from data exported from our financial management system, the data from the Auxiliary Voucher appears on one column and the data from the Disbursement voucher appears on the next column in excel, what am doing currently is manually look for one figure at a time and delete the ones that match, i need help on how to make excel do this automatically , please help!

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Trying to match data in different columns

    Lex, welcome to the Board however please note:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

+ 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