Aman Chalotra
New Member
- Joined
- Mar 9, 2017
- Messages
- 14
Hi All !!!
I have a routine work which i wish to automate with the help of VBA macro. I have a sheet with say 8 employees. I want to fetch there monthly salary from other sheet. Previously I was having only one sheet to get salary value but now I have to get it form multiple sheets. Here I want to search employee salary wrt to Employee ID from two sheets June and April. And paste in sheet1 next to employee name in two columns.
I was easy to use vlookup macro recorder but with sheets increasing its not a good Idea to use macro recorder. I have tried hard but not able to get the string to start code.
Please provide a basic code to get values.
My main sheet looks like this i.e. sheet1 :
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl69, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Name[/TD]
[TD="class: xl67, width: 64"]June[/TD]
[TD="class: xl67, width: 64"]April[/TD]
[/TR]
[TR]
[TD="class: xl66"]D03[/TD]
[TD="class: xl67"]Jammes[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D04[/TD]
[TD="class: xl67"]Mathew[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl66"]D15[/TD]
[TD="class: xl67"]Anderson[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D20[/TD]
[TD="class: xl67"]Hayden[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D12[/TD]
[TD="class: xl67"]Stuart[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D09[/TD]
[TD="class: xl67"]Broad[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl68"]D30[/TD]
[TD="class: xl67"]Donald[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
</tbody>[/TABLE]
Destination sheet One i.e. June is
[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl70, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Salary[/TD]
[/TR]
[TR]
[TD="class: xl68"]D03[/TD]
[TD="class: xl69, align: right"]1000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D04[/TD]
[TD="class: xl69, align: right"]2000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D05[/TD]
[TD="class: xl69, align: right"]3000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D06[/TD]
[TD="class: xl69, align: right"]4000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D07[/TD]
[TD="class: xl69, align: right"]5000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D08[/TD]
[TD="class: xl69, align: right"]6000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D09[/TD]
[TD="class: xl69, align: right"]7000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D10[/TD]
[TD="class: xl69, align: right"]8000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D11[/TD]
[TD="class: xl69, align: right"]9000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D12[/TD]
[TD="class: xl69, align: right"]10000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D13[/TD]
[TD="class: xl69, align: right"]11000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D14[/TD]
[TD="class: xl69, align: right"]12000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D15[/TD]
[TD="class: xl69, align: right"]13000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D16[/TD]
[TD="class: xl69, align: right"]14000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D17[/TD]
[TD="class: xl69, align: right"]15000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D18[/TD]
[TD="class: xl69, align: right"]16000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D19[/TD]
[TD="class: xl69, align: right"]17000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D20[/TD]
[TD="class: xl69, align: right"]18000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D21[/TD]
[TD="class: xl69, align: right"]19000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D22[/TD]
[TD="class: xl69, align: right"]20000[/TD]
[/TR]
</tbody>[/TABLE]
And second destination sheet i.e. April is:
[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl70, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Salary[/TD]
[/TR]
[TR]
[TD="class: xl68"]D03[/TD]
[TD="class: xl69, align: right"]100000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D04[/TD]
[TD="class: xl69, align: right"]150000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D05[/TD]
[TD="class: xl69, align: right"]200000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D06[/TD]
[TD="class: xl69, align: right"]250000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D07[/TD]
[TD="class: xl69, align: right"]300000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D08[/TD]
[TD="class: xl69, align: right"]350000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D09[/TD]
[TD="class: xl69, align: right"]400000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D10[/TD]
[TD="class: xl69, align: right"]450000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D11[/TD]
[TD="class: xl69, align: right"]500000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D12[/TD]
[TD="class: xl69, align: right"]550000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D13[/TD]
[TD="class: xl69, align: right"]600000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D14[/TD]
[TD="class: xl69, align: right"]650000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D15[/TD]
[TD="class: xl69, align: right"]700000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D16[/TD]
[TD="class: xl69, align: right"]750000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D17[/TD]
[TD="class: xl69, align: right"]800000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D18[/TD]
[TD="class: xl69, align: right"]850000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D19[/TD]
[TD="class: xl69, align: right"]900000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D20[/TD]
[TD="class: xl69, align: right"]950000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D21[/TD]
[TD="class: xl69, align: right"]1000000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D22[/TD]
[TD="class: xl69, align: right"]1050000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D23[/TD]
[TD="class: xl69, align: right"]1100000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D24[/TD]
[TD="class: xl69, align: right"]1150000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D25[/TD]
[TD="class: xl69, align: right"]1200000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D26[/TD]
[TD="class: xl69, align: right"]1250000[/TD]
[/TR]
[TR]
[TD="class: xl71"]D27[/TD]
[TD="align: right"]1300000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D28[/TD]
[TD="align: right"]1350000[/TD]
[/TR]
</tbody>[/TABLE]
I have a routine work which i wish to automate with the help of VBA macro. I have a sheet with say 8 employees. I want to fetch there monthly salary from other sheet. Previously I was having only one sheet to get salary value but now I have to get it form multiple sheets. Here I want to search employee salary wrt to Employee ID from two sheets June and April. And paste in sheet1 next to employee name in two columns.
I was easy to use vlookup macro recorder but with sheets increasing its not a good Idea to use macro recorder. I have tried hard but not able to get the string to start code.
Please provide a basic code to get values.
My main sheet looks like this i.e. sheet1 :
[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl69, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Name[/TD]
[TD="class: xl67, width: 64"]June[/TD]
[TD="class: xl67, width: 64"]April[/TD]
[/TR]
[TR]
[TD="class: xl66"]D03[/TD]
[TD="class: xl67"]Jammes[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D04[/TD]
[TD="class: xl67"]Mathew[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl66"]D15[/TD]
[TD="class: xl67"]Anderson[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D20[/TD]
[TD="class: xl67"]Hayden[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D12[/TD]
[TD="class: xl67"]Stuart[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl67"]D09[/TD]
[TD="class: xl67"]Broad[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
[TR]
[TD="class: xl68"]D30[/TD]
[TD="class: xl67"]Donald[/TD]
[TD="class: xl67"][/TD]
[TD="class: xl67"][/TD]
[/TR]
</tbody>[/TABLE]
Destination sheet One i.e. June is
[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl70, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Salary[/TD]
[/TR]
[TR]
[TD="class: xl68"]D03[/TD]
[TD="class: xl69, align: right"]1000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D04[/TD]
[TD="class: xl69, align: right"]2000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D05[/TD]
[TD="class: xl69, align: right"]3000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D06[/TD]
[TD="class: xl69, align: right"]4000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D07[/TD]
[TD="class: xl69, align: right"]5000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D08[/TD]
[TD="class: xl69, align: right"]6000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D09[/TD]
[TD="class: xl69, align: right"]7000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D10[/TD]
[TD="class: xl69, align: right"]8000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D11[/TD]
[TD="class: xl69, align: right"]9000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D12[/TD]
[TD="class: xl69, align: right"]10000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D13[/TD]
[TD="class: xl69, align: right"]11000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D14[/TD]
[TD="class: xl69, align: right"]12000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D15[/TD]
[TD="class: xl69, align: right"]13000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D16[/TD]
[TD="class: xl69, align: right"]14000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D17[/TD]
[TD="class: xl69, align: right"]15000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D18[/TD]
[TD="class: xl69, align: right"]16000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D19[/TD]
[TD="class: xl69, align: right"]17000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D20[/TD]
[TD="class: xl69, align: right"]18000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D21[/TD]
[TD="class: xl69, align: right"]19000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D22[/TD]
[TD="class: xl69, align: right"]20000[/TD]
[/TR]
</tbody>[/TABLE]
And second destination sheet i.e. April is:
[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl70, width: 64"]ID[/TD]
[TD="class: xl69, width: 64"]Salary[/TD]
[/TR]
[TR]
[TD="class: xl68"]D03[/TD]
[TD="class: xl69, align: right"]100000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D04[/TD]
[TD="class: xl69, align: right"]150000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D05[/TD]
[TD="class: xl69, align: right"]200000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D06[/TD]
[TD="class: xl69, align: right"]250000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D07[/TD]
[TD="class: xl69, align: right"]300000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D08[/TD]
[TD="class: xl69, align: right"]350000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D09[/TD]
[TD="class: xl69, align: right"]400000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D10[/TD]
[TD="class: xl69, align: right"]450000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D11[/TD]
[TD="class: xl69, align: right"]500000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D12[/TD]
[TD="class: xl69, align: right"]550000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D13[/TD]
[TD="class: xl69, align: right"]600000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D14[/TD]
[TD="class: xl69, align: right"]650000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D15[/TD]
[TD="class: xl69, align: right"]700000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D16[/TD]
[TD="class: xl69, align: right"]750000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D17[/TD]
[TD="class: xl69, align: right"]800000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D18[/TD]
[TD="class: xl69, align: right"]850000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D19[/TD]
[TD="class: xl69, align: right"]900000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D20[/TD]
[TD="class: xl69, align: right"]950000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D21[/TD]
[TD="class: xl69, align: right"]1000000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D22[/TD]
[TD="class: xl69, align: right"]1050000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D23[/TD]
[TD="class: xl69, align: right"]1100000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D24[/TD]
[TD="class: xl69, align: right"]1150000[/TD]
[/TR]
[TR]
[TD="class: xl68"]D25[/TD]
[TD="class: xl69, align: right"]1200000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D26[/TD]
[TD="class: xl69, align: right"]1250000[/TD]
[/TR]
[TR]
[TD="class: xl71"]D27[/TD]
[TD="align: right"]1300000[/TD]
[/TR]
[TR]
[TD="class: xl69"]D28[/TD]
[TD="align: right"]1350000[/TD]
[/TR]
</tbody>[/TABLE]