-2

I have two separate worksheets that I would like to search in and then populate a column if two columns represent the same data. I'm having a hard time explaining this so please have patience.

I have worksheet1 with column "A" having text and numbers in it. In the same sheet column "B" has the data that I want to show in worksheet2 if Both Column "A" match in both worksheets.


Example:

Worksheet1

Column A

Text text text (2012-R-0000)

blah blah blah

text text text (2012-R-0001)

Column B

20-204

20-405

40-609

Worksheet2

Column A

2012-R-0000

2012-R-0001

Column E

(empty) I would like the data in Worksheet1 Column B to be placed here.

Thank you in advance for any assistance with my question.

babou
  • 237
  • 1
  • 14
  • If you have difficulties achieving this in VBA, do it step by step. Learn how to loop over the cells in one column, how to check if two cells have the same value, how to check for partial matches in strings, how to reference cells on different worksheets. You might also consider using worksheet formulas for this. – arcadeprecinct Jul 11 '16 at 10:36
  • Try using `Application.WorksheetFunction.VLookup` to compare between the two worksheets. Good begining will be to search this site, one example for instance can be found: http://stackoverflow.com/questions/20739717/vba-vlookup-reference-in-different-sheet – Shai Rado Jul 11 '16 at 10:48

2 Answers2

1

Assuming your worksheet 1 and worksheet 2 datas starts with A1

use the below formula at worksheet 2 in E1

=VLOOKUP("*"&A1&"*",Sheet3!A:B,2,FALSE)

French Formula:

=RECHERCHEV("*"&A1&"*";Sheet3!A:B;2;FALSE)

and drag down

Proof of Work enter image description here

Karthick Gunasekaran
  • 2,697
  • 1
  • 15
  • 25
0

Use VLookUp in Worksheet 2 like this.

In cell E1 of Worksheet 2 write the following:

=VLOOKUP(A1;Worksheet1!$A$1:$B$30;2;FALSE)

Then simply drag the formula down. It will match the first column from both worksheets, then paste the corresponding data from column B in worksheet1 to column E in worksheet 2. You'll have to edit "Worksheet1" to match the name of the acctual worksheet, and the number 30 to match the number of rows in worksheet 1.

Carmelid
  • 228
  • 3
  • 6