Look for Multiple Matches for a given range

tayyabq8

New Member
Joined
Jul 6, 2014
Messages
2
I'm in need of your help to figure out the following. I have following lookup data:
Code:
<code>Account Code1    Account Code2    Description1    Description 2 
2500                              B/Sheet        Receivable 
2508                              B/Sheet        Payable 
2504                              PL        Sales</code>
I'm looking for Account code 1 in following range and pickup all the instances of Code 1 in this range and put in Account Code 2.
Code:
<code>
Account Code1    Account Code2 
2500             20100 
2508             45000 
2500             20300 
2504             24000 
2500             70000 
2508             40300</code>
This is the output which I'm looking for:
Code:
<code>Output              
Account Code1    Account Code2    Description1    Description 2              
2500             20100            B/Sheet         Receivable 
2500             20300            B/Sheet         Receivable 
2500             70000            B/Sheet         Receivable 
2508             45000            B/Sheet         Payable 
2508             40300            B/Sheet         Payable 
2504             24000            PL              Sales</code>
I am looking for a VBA code which looks for all possible matches for a given number and inserts those many rows.

I know it is achievable in Excel but I am very naive when it comes to Excel related stuff, can someone please help me with this?

Regards,
 
Last edited:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You really only need to use VlookUp, take your data, lets say its sheet1 that your complete data is on and you want to populate sheet2 Code2, enter this formula in sheet2 code2's first available cell and then copy down =VLOOKUP($A2,Sheet1!$A:$B,2,FALSE)
 
Upvote 0
You really only need to use VlookUp, take your data, lets say its sheet1 that your complete data is on and you want to populate sheet2 Code2, enter this formula in sheet2 code2's first available cell and then copy down =VLOOKUP($A2,Sheet1!$A:$B,2,FALSE)
Hello Simon

Thanks for your reply. Problem is that, my data and lookup range (where im looking for match) has one-to-many relation, means for 2500, I have got more than one match and I don't know how many? It is random. Vlookup always returns the first match and I have no way to look for rest of the matches. Any ideas please?
 
Upvote 0
Looking at your data how will you possibly be able to to tell which number belongs to which code, take 2500, by searching through the available 2500's on the data sheet how will you be able to distinguish which code2 gets put next to which 2500 code?
 
Upvote 0
Hi,
try ths with CSE (Ctl+Shift+Enter)
in this example
$B$1:$B$10 is your result column (where u want to get account code2 for account code1)
A$1:A$10 is account code1 range
$E1 - is your critera

=INDEX($B$1:$B$10,SMALL(IF((A$1:A$10=$E1)*(ROW(A$1:A$10))<>0,(A$1:A$10=$E1)*(ROW(A$1:A$10))),COUNTIF($E$1:E1,E1)),1)
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top