aravindh8686
New Member
- Joined
- Oct 31, 2018
- Messages
- 5
I have two workbooks M.xlsx and Lable DB.xlsm. I need VBA to compare this two workbook column A which has matching values, and when values are matched copy the corresponding Col B and Col C datas from Lable DB.xlsm to the matched value of M.xlsx workbook.
Some condition:
I searched lot in online and tried to use some codes which may satisfy my requirement, but I couldnt rightly choose since I am not more familiar with codes. Kindly help.
M.xlsx looks like
COL A COL B COL C
[TABLE="width: 224"]
<tbody>[TR]
[TD]FPSMC
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]62/85R2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]74DC
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]85R2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]86F-2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]CFL
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]DS1
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
Lable DB.xlsm workbook looks like
COL A COL B COL C
[TABLE="width: 224"]
<tbody>[TR]
[TD]62/85R2
[/TD]
[TD]SYS1
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]74DC
[/TD]
[TD]SYS2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]85R2
[/TD]
[TD]SYS5
[/TD]
[TD]DATABASE
[/TD]
[/TR]
[TR]
[TD]FPSMC
[/TD]
[TD]SYS8
[/TD]
[TD]BLOCK
[/TD]
[/TR]
[TR]
[TD]CFL
[/TD]
[TD]SYS6
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]DS1
[/TD]
[TD]SYS3
[/TD]
[TD]DB3
[/TD]
[/TR]
[TR]
[TD]86F-2
[/TD]
[TD]SYS9
[/TD]
[TD]CKT
[/TD]
[/TR]
</tbody>[/TABLE]
Expected result in M.xlsx
COL A COL B COL C
[TABLE="width: 224"]
<tbody>[TR]
[TD]FPSMC
[/TD]
[TD]SYS8
[/TD]
[TD]BLOCK
[/TD]
[/TR]
[TR]
[TD]62/85R2
[/TD]
[TD]SYS1
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]74DC
[/TD]
[TD]SYS2
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]85R2
[/TD]
[TD]SYS5
[/TD]
[TD]DATABASE
[/TD]
[/TR]
[TR]
[TD]86F-2
[/TD]
[TD]SYS9
[/TD]
[TD]CKT
[/TD]
[/TR]
[TR]
[TD]CFL
[/TD]
[TD]SYS6
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]DS1
[/TD]
[TD]SYS3
[/TD]
[TD]DB3
[/TD]
[/TR]
</tbody>[/TABLE]
Some condition:
- I will place both files in one folder.
- M.xlsx , workbooks worksheet name may be different each time.And it may not be open all time.
- Macro will be runned from Lable DB.xlsm
- After pasting datas to M.xlsx, it will save and close the workbook.
I searched lot in online and tried to use some codes which may satisfy my requirement, but I couldnt rightly choose since I am not more familiar with codes. Kindly help.
M.xlsx looks like
COL A COL B COL C
[TABLE="width: 224"]
<tbody>[TR]
[TD]FPSMC
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]62/85R2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]74DC
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]85R2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]86F-2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]CFL
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]DS1
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]
Lable DB.xlsm workbook looks like
COL A COL B COL C
[TABLE="width: 224"]
<tbody>[TR]
[TD]62/85R2
[/TD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