CODE for matching a name in a workbook and replacing info in a workbook.


I'm brand new at writing macros, and I'm trying to write a macro that does this. I want to have 2 workbooks side my side. Workbook A and B. I want to compare workbook A and B by checking for matches in one column and if it finds a match in workbook B, then I want to replace something in another column in workbook B with the same information as workbook A.




Since you are brand new to programming I urge you not to start with a difficult taks like the one you describe. This is because you will need some very advanced programming just to handle two workbooks at the same time. You might avoid that problem by first copying both worksheets into the same workbook. At least, in this way there will be no question as to where the code should reside.

For the rest of your plan you might make programming easier if you change your work instruction. You say you want to find a match between A and B. Basically, you want to find a particular data set (row) in worksheet B. There are many methods of doing that. Your description is insufficient to recommend one.

Once you have found the match you wish to take specific action. This is a very normal process, too. You don't describe it. Therefore all I can say is to encourage you: this is easy - just keep the action logically separate from the search for a match (not to mention from finding the workbook containing the worksheets).

Of course, if you know what you want done when a match is found you must also prepare for the eventuality that it isn't. Beginners often overlook this need. When you write code you normally let it end when no action is required.


Answer the Question

You must create an account to use the forum. Create an Account or Login