Lookup, Copy, Replace

sus82

New Member
Joined
May 11, 2011
Messages
2
Hello Expert,

I need your help with this query.
i have 2 sheet. 1st sheet contains 2 column data
2nd sheet also contains 2 column data but 2nd matching column with sheet 1
I want to look for a cell in 2nd sheet and copy all rows from sheet 1 and replace copied rows 1st cell value with a value from 1st cell of 2nd sheet and keep adding rows.

<table style="width: 159px; height: 336px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 48pt;" width="64"> <col style="width: 61pt;" width="81"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 48pt;" width="64" height="20">Sheet1</td> <td style="width: 61pt;" width="81">
</td> </tr> <tr style="height: 15pt;" height="20"> <td style="height: 15pt;" height="20">ColA</td> <td>Col B</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt;" height="20">abc31</td> <td class="xl63" style="border-left: medium none;">dreamxyz1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc31</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz2</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc34</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz7</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc34</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz8</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc34</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz9</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc34</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz10</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc36</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz11</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc36</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz12</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc36</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz13</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc37</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz14</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc37</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz17</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc37</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz18</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc43</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz19</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; border-top: medium none;" height="20">abc43</td> <td class="xl63" style="border-top: medium none; border-left: medium none;">dreamxyz20</td> </tr> </tbody></table>

=======================================
<table width="128" border="0" cellpadding="0" cellspacing="0"><col style="width: 48pt;" width="64" span="2"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 48pt;" width="64" height="20">Sheet2</td> <td style="width: 48pt;" width="64">
</td> </tr> <tr style="height: 15pt;" height="20"> <td style="height: 15pt;" height="20">Col A</td> <td>Col B</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" height="20">data1</td> <td class="xl65" style="border-left: medium none;">abc31</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data2</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc31</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data3</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc31</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data4</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc34</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data5</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc34</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data6</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc36</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data7</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data8</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data9</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data10</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data11</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data12</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data13</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc43</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data14</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc43</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data15</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">abc43</td> </tr> </tbody></table>=======================================================
Final requested result

<table width="159" border="0" cellpadding="0" cellspacing="0"><col style="width: 59pt;" width="78"> <col style="width: 61pt;" width="81"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 59pt;" width="78" height="20">Final Sheet</td> <td style="width: 61pt;" width="81">
</td> </tr> <tr style="height: 15pt;" height="20"> <td style="height: 15pt;" height="20">Column A</td> <td>Column B</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt;" height="20">data1</td> <td class="xl65" style="border-left: medium none;">dreamxyz1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data1</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz2</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data2</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data2</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz2</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data3</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz1</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data3</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz2</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data4</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz7</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data4</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz8</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data4</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz9</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data4</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz10</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data5</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz7</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data5</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz8</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data5</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz9</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data5</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz10</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data6</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz11</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data6</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz12</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">data6</td> <td class="xl65" style="border-top: medium none; border-left: medium none;">dreamxyz13</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt;" height="20">............contd..........................</td> <td>
</td> </tr> </tbody></table>

request you to help me to achieve this via macro
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,224,616
Messages
6,179,911
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top