Matching the data across column and rows using VBA

chauhananirudh2012

New Member
Joined
Oct 22, 2019
Messages
2
[COLOR=#BBC0C4 !important][COLOR=#6A737C !important]

[/COLOR]
[/COLOR]
I have two sheets:
Sheet 1 consist of :

3phsx.png

Sheet 2 consist of :
MkaiM.png

And the output should show in M column in Sheet1. I am attaching the sample output here :
LIKlo.png

So,what I have here is ID in Sheet 1, for eg : ID 'US' has Abhay,Carl and Dev and in Sheet3, I have names in column and ID in Rows. What i want is my Sample output column should populate using macro based on matched values from Sheet3
I am using below logic but something is going wrong :
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">For i = 2 To 10
j
= i + 1
If ThisWorkbook.Sheets("Input").Range("N" & i) = ThisWorkbook.Sheets("Sheet3").Range("A" & i) And ThisWorkbook.Sheets("Input").Range("K" & i) = ThisWorkbook.Sheets("Sheet3").Range("B1") Then
ThisWorkbook
.Sheets("Input").Range("O" & i) = ThisWorkbook.Sheets("Sheet3").Range("B" & j)
End If
Next i</code>

I know this can be done with vlookup, but How can Vlookup satisfies two criterias of matching? Moreover, I have 2000+ data.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
2000 rows of data isn't that much for Excel, so I would still consider using a formula approach. Here is one.

Excel Workbook
ABC
1USNA
2Name
3AbhayData 1Data 7
4CarlData 2Data 8
5DevData 3Data 9
6NargData 4Data 10
7SitaData 5Data 11
8GeetaData 6Data 12
Sheet2




Excel Workbook
KLM
1IDNameOutput
2USAbhayData 1
3carlData 2
4DevData 3
5NACarlData 8
6NargData 10
7SitaData 11
8GeetaData 12
Sheet1




BTW, for future reference, you will get many more potential helpers if you post any sample data in small copyable screen shots in your post. That way people can copy your sample data to a worksheet to test (most helpers don’t like having to type out test data). My signature block below has a link for several ways to do that. Test them in the Test Here forum. That way, if something goes wrong, you won’t be messing up a main forum.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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