We help IT Professionals succeed at work.
Get Started

VBA :Match columns from from workbook A & B, return another column from workbook A to workbook B

Last Modified: 2018-02-02
I have 2 workbooks A & B.The workbooks are already defined.

I have an issue with part of my code where I am trying to compare column A from workbook A and Column D from Workbook B. If it matches then I want to copy corresponding column B to Workbook column E.

I started to write the following code but not sure how to proceed further in comparing the columns and copying as I am fairly new to VBA. I am not trying to match row by row, I am checking the entire column.

Dim strRangeToCheckA As Range
Dim strRangeToCheckB As Range
Dim strRangeToCheckC As Variant

Set strRangeToCheckA = RSC.Sheets("Balance").Range("A:G")
Set strRangeToCheckB = Brostacc.Sheets("Stock").Range("A:U")
Set strRangeToCheckC = Brostacc.Sheets("Stock").Range("U:U")

If Application.VLookup(LookFor, strRangeToCheckA, 2, False) = Application.VLookup(LookFor, strRangeToCheckB, 1, False) Then
  strRangeToCheckC = Application.VLookup(LookFor, strRangeToCheckA, 7, False)
End If

I appreciate the help and Thanks in Advance!
Watch Question
Keep everyone healthy; Wear a mask - Social distance - Don't touch your face - Wash your hands for 20 seconds
Most Valuable Expert 2017
Distinguished Expert 2020
This problem has been solved!
Unlock 1 Answer and 15 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE