Copy one column to another based on a Criteria (MS

2019-08-30 22:28发布

I've Two sheets, Sheet1, Sheet2

Sheet1:

A   | B
-----
123 |
456 |
789 | 

Sheet 2:

A   | B
-----
123 | DATA1
789 | DATA2
456 | DATA3

I want The Sheet1 to have the following output:

A   | B
-----
123 | DATA1
456 | DATA3
789 | DATA2

I have a very basic VB knowledge, how can I accomplish this?

1条回答
Anthone
2楼-- · 2019-08-30 23:06

Sheet1, cell B1: =VLOOKUP(A1,Sheet2!$A$1:$B$3,2,0) and drag down should give the desired result

Edit (VBA solution): Sheet1.Range("B1:B3").Formula = "=VLOOKUP(A1,Sheet2!$A$1:$B$3,2,0)"

查看更多
登录 后发表回答