Derrek
Derrek

Reputation: 1

Macro that fills column based on two other columns equating

I am new to writing macros and I have no clue on how to write this. I need a macro that compares text in column A of workbook A to column B in Workbook B. If they match, then it would use the data in Column D on that same row of workbook A and place it in Column C of workbook B. If no matches were found, then it would say "No Match". How would I create this? An example is below:

            Workbook A                                        Workbook B
     Column A  Column B  Column D                Column A   Column B   Column C
      Smith      --       Name                    ---        Point      No Match        
      Lane       --       Street                  ---        Smith      Name 
      Happy      --       Emotion                 ---        123        Numbers
      123        --       Numbers                 ---        Valid      No Match 

Upvotes: 0

Views: 409

Answers (1)

Adam Clason
Adam Clason

Reputation: 321

You won't need macros to do this. All you will need is an if condition something like this

=IF('[WorkbookName1.xlsx]Sheet1'!A1='[WorkbookName2.xlsx]Sheet2'!B1, '[WorkbookName1.xlsx]Sheet1'!D1, "No Match")

Just drag that formula down (or create it in vba with ".Formula = ") for all of the cells in column C. Let me know if you need help with adding the formulas to the correct cells from VBA if that is indeed necessary

Upvotes: 2

Related Questions