kevinh2320
Board Regular
- Joined
- May 13, 2016
- Messages
- 61
I have two worksheets in my workbook. Sheet1 contains customer order information with column A holding their account number. Sheet2 contains customers name & address information with column A also holding their account number. I need VBA code to start at cell A2 of sheet1 and check the account number. Then move to Sheet2's column A to see if there is a matching account number. If there is a match copy cells "B" through "F" of that row, then return to that accounts row in Sheet1 and paste the Company Name, Address, City, State, ZipCode in cells F through J of that row. Code needs to loop through the entire column A of sheet1 until complete. If there are account numbers that don't match code should just move to the next row until complete.
Hope this make sense. Example sheets 1 & 2 shown below. Thanks for any help.
<colgroup><col style="width: 107px"><col width="100"><col width="100"><col width="100"><col width="100"></colgroup><tbody>[TR]
[TD]Acct#[/TD]
[TD]Part#[/TD]
[TD]Qty[/TD]
[TD]UnitPrice[/TD]
[TD]Ttl[/TD]
[/TR]
[TR]
[TD]123456[/TD]
[TD="align: right"]544[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]$175.00[/TD]
[TD="align: right"]$2,625.00[/TD]
[/TR]
[TR]
[TD]133987[/TD]
[TD="align: right"]443[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]$100.00[/TD]
[TD="align: right"]$3,500.00[/TD]
[/TR]
[TR]
[TD]239395[/TD]
[TD="align: right"]434[/TD]
[TD="align: right"]66[/TD]
[TD="align: right"]$5.00[/TD]
[TD="align: right"]$330.00[/TD]
[/TR]
[TR]
[TD]102102[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$1,815.00[/TD]
[/TR]
[TR]
[TD]239395[/TD]
[TD="align: right"]544[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]$85.00[/TD]
[TD="align: right"]$765.00[/TD]
[/TR]
[TR]
[TD]433202[/TD]
[TD="align: right"]132[/TD]
[TD="align: right"]94[/TD]
[TD="align: right"]$35.00[/TD]
[TD="align: right"]$3,290.00[/TD]
[/TR]
[TR]
[TD]103111[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$8,250.00[/TD]
[/TR]
[TR]
[TD]244365[/TD]
[TD="align: right"]333[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]$100.00[/TD]
[TD="align: right"]$5,000.00[/TD]
[/TR]
[TR]
[TD]411555[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$935.00[/TD]
[/TR]
[TR]
[TD]244987-A[/TD]
[TD="align: right"]233[/TD]
[TD="align: right"]1543[/TD]
[TD="align: right"]$1.50[/TD]
[TD="align: right"]$2,314.50[/TD]
[/TR]
</tbody>[/TABLE]
Sheet2 Example
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>[TABLE="width: 0"]
<colgroup><col style="width: 107px"><col width="163"><col width="132"><col width="100"><col width="100"><col width="100"></colgroup><tbody>[TR]
[TD]Acct#[/TD]
[TD]CompanyName[/TD]
[TD]Address[/TD]
[TD]City[/TD]
[TD]State[/TD]
[TD]ZipCode[/TD]
[/TR]
[TR]
[TD="align: right"]123456[/TD]
[TD]ABC Company[/TD]
[TD]123 Lost Ln[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98555[/TD]
[/TR]
[TR]
[TD="align: right"]102102[/TD]
[TD]Hawk Industries[/TD]
[TD]3600 W. 2nd Ave[/TD]
[TD]Kent[/TD]
[TD]WA[/TD]
[TD="align: right"]98366[/TD]
[/TR]
[TR]
[TD="align: right"]103111[/TD]
[TD]J&J Co.[/TD]
[TD]P.O. Box 10[/TD]
[TD]Kirkland[/TD]
[TD]WA[/TD]
[TD="align: right"]98111[/TD]
[/TR]
[TR]
[TD="align: right"]133987[/TD]
[TD]Snip & Clip[/TD]
[TD]P.O. Box 25[/TD]
[TD]Tacoma[/TD]
[TD]WA[/TD]
[TD="align: right"]98232[/TD]
[/TR]
[TR]
[TD="align: right"]244365[/TD]
[TD]Performance Max[/TD]
[TD]434 Anywhere Pl[/TD]
[TD]Sometown[/TD]
[TD]WA[/TD]
[TD="align: right"]98765[/TD]
[/TR]
[TR]
[TD="align: right"]239395[/TD]
[TD]Joe Joe's[/TD]
[TD]765 Where St.[/TD]
[TD]Anytown [/TD]
[TD]WA[/TD]
[TD="align: right"]98767[/TD]
[/TR]
[TR]
[TD="align: right"]239395[/TD]
[TD]Automax West[/TD]
[TD]P.O. Box 15776[/TD]
[TD]Lost City[/TD]
[TD]CA[/TD]
[TD="align: right"]92888[/TD]
[/TR]
[TR]
[TD="align: right"]244987-A[/TD]
[TD]Tudle Row[/TD]
[TD]6434 Salem St.[/TD]
[TD]Tacoma[/TD]
[TD]WA[/TD]
[TD="align: right"]98232[/TD]
[/TR]
[TR]
[TD="align: right"]433202[/TD]
[TD]Brewmiesters Cache[/TD]
[TD]101 Whiskey Pl.[/TD]
[TD]Redmond[/TD]
[TD]WA[/TD]
[TD="align: right"]98664[/TD]
[/TR]
[TR]
[TD="align: right"]411555[/TD]
[TD]J. Co.[/TD]
[TD]888 Maple St.[/TD]
[TD]Tukwilla[/TD]
[TD]WA[/TD]
[TD="align: right"]98334[/TD]
[/TR]
[TR]
[TD="align: right"]388998[/TD]
[TD]BnB Traders[/TD]
[TD]P.O. Box 7[/TD]
[TD]Anchorage[/TD]
[TD]AK[/TD]
[TD="align: right"]99510[/TD]
[/TR]
[TR]
[TD="align: right"]325463[/TD]
[TD]CC Co.[/TD]
[TD]1243 Made Up Ln.[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98765[/TD]
[/TR]
[TR]
[TD="align: right"]333321[/TD]
[TD]Music World[/TD]
[TD]555 5th Ave.[/TD]
[TD]Edmonds[/TD]
[TD]WA[/TD]
[TD="align: right"]98768[/TD]
[/TR]
[TR]
[TD="align: right"]383009[/TD]
[TD]Pets and Pamper[/TD]
[TD]4787 3rd St.[/TD]
[TD]Kent[/TD]
[TD]WA[/TD]
[TD="align: right"]98366[/TD]
[/TR]
[TR]
[TD="align: right"]520020[/TD]
[TD]Industrial Supply Inc.[/TD]
[TD]88457 54th Ave.[/TD]
[TD]Ballard[/TD]
[TD]WA[/TD]
[TD="align: right"]98444[/TD]
[/TR]
[TR]
[TD="align: right"]500011[/TD]
[TD]Recreational Adventures[/TD]
[TD]232 Easy St.[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98437[/TD]
[/TR]
[TR]
[TD="align: right"]655837[/TD]
[TD]Zip Deliveries[/TD]
[TD]343 4th Ave[/TD]
[TD]Mt. Vernon[/TD]
[TD]WA[/TD]
[TD="align: right"]98876[/TD]
[/TR]
[TR]
[TD="align: right"]299534-B[/TD]
[TD]Green Thumb Landscaping[/TD]
[TD]400 Cherry Dr.[/TD]
[TD]Lynnwood[/TD]
[TD]WA[/TD]
[TD="align: right"]98554[/TD]
[/TR]
</tbody>[/TABLE]
Hope this make sense. Example sheets 1 & 2 shown below. Thanks for any help.
Sheet1 Example
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>[TABLE="width: 0"]<colgroup><col style="width: 107px"><col width="100"><col width="100"><col width="100"><col width="100"></colgroup><tbody>[TR]
[TD]Acct#[/TD]
[TD]Part#[/TD]
[TD]Qty[/TD]
[TD]UnitPrice[/TD]
[TD]Ttl[/TD]
[/TR]
[TR]
[TD]123456[/TD]
[TD="align: right"]544[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]$175.00[/TD]
[TD="align: right"]$2,625.00[/TD]
[/TR]
[TR]
[TD]133987[/TD]
[TD="align: right"]443[/TD]
[TD="align: right"]35[/TD]
[TD="align: right"]$100.00[/TD]
[TD="align: right"]$3,500.00[/TD]
[/TR]
[TR]
[TD]239395[/TD]
[TD="align: right"]434[/TD]
[TD="align: right"]66[/TD]
[TD="align: right"]$5.00[/TD]
[TD="align: right"]$330.00[/TD]
[/TR]
[TR]
[TD]102102[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]33[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$1,815.00[/TD]
[/TR]
[TR]
[TD]239395[/TD]
[TD="align: right"]544[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]$85.00[/TD]
[TD="align: right"]$765.00[/TD]
[/TR]
[TR]
[TD]433202[/TD]
[TD="align: right"]132[/TD]
[TD="align: right"]94[/TD]
[TD="align: right"]$35.00[/TD]
[TD="align: right"]$3,290.00[/TD]
[/TR]
[TR]
[TD]103111[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$8,250.00[/TD]
[/TR]
[TR]
[TD]244365[/TD]
[TD="align: right"]333[/TD]
[TD="align: right"]50[/TD]
[TD="align: right"]$100.00[/TD]
[TD="align: right"]$5,000.00[/TD]
[/TR]
[TR]
[TD]411555[/TD]
[TD="align: right"]444[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]$55.00[/TD]
[TD="align: right"]$935.00[/TD]
[/TR]
[TR]
[TD]244987-A[/TD]
[TD="align: right"]233[/TD]
[TD="align: right"]1543[/TD]
[TD="align: right"]$1.50[/TD]
[TD="align: right"]$2,314.50[/TD]
[/TR]
</tbody>[/TABLE]
Sheet2 Example
<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>[TABLE="width: 0"]
<colgroup><col style="width: 107px"><col width="163"><col width="132"><col width="100"><col width="100"><col width="100"></colgroup><tbody>[TR]
[TD]Acct#[/TD]
[TD]CompanyName[/TD]
[TD]Address[/TD]
[TD]City[/TD]
[TD]State[/TD]
[TD]ZipCode[/TD]
[/TR]
[TR]
[TD="align: right"]123456[/TD]
[TD]ABC Company[/TD]
[TD]123 Lost Ln[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98555[/TD]
[/TR]
[TR]
[TD="align: right"]102102[/TD]
[TD]Hawk Industries[/TD]
[TD]3600 W. 2nd Ave[/TD]
[TD]Kent[/TD]
[TD]WA[/TD]
[TD="align: right"]98366[/TD]
[/TR]
[TR]
[TD="align: right"]103111[/TD]
[TD]J&J Co.[/TD]
[TD]P.O. Box 10[/TD]
[TD]Kirkland[/TD]
[TD]WA[/TD]
[TD="align: right"]98111[/TD]
[/TR]
[TR]
[TD="align: right"]133987[/TD]
[TD]Snip & Clip[/TD]
[TD]P.O. Box 25[/TD]
[TD]Tacoma[/TD]
[TD]WA[/TD]
[TD="align: right"]98232[/TD]
[/TR]
[TR]
[TD="align: right"]244365[/TD]
[TD]Performance Max[/TD]
[TD]434 Anywhere Pl[/TD]
[TD]Sometown[/TD]
[TD]WA[/TD]
[TD="align: right"]98765[/TD]
[/TR]
[TR]
[TD="align: right"]239395[/TD]
[TD]Joe Joe's[/TD]
[TD]765 Where St.[/TD]
[TD]Anytown [/TD]
[TD]WA[/TD]
[TD="align: right"]98767[/TD]
[/TR]
[TR]
[TD="align: right"]239395[/TD]
[TD]Automax West[/TD]
[TD]P.O. Box 15776[/TD]
[TD]Lost City[/TD]
[TD]CA[/TD]
[TD="align: right"]92888[/TD]
[/TR]
[TR]
[TD="align: right"]244987-A[/TD]
[TD]Tudle Row[/TD]
[TD]6434 Salem St.[/TD]
[TD]Tacoma[/TD]
[TD]WA[/TD]
[TD="align: right"]98232[/TD]
[/TR]
[TR]
[TD="align: right"]433202[/TD]
[TD]Brewmiesters Cache[/TD]
[TD]101 Whiskey Pl.[/TD]
[TD]Redmond[/TD]
[TD]WA[/TD]
[TD="align: right"]98664[/TD]
[/TR]
[TR]
[TD="align: right"]411555[/TD]
[TD]J. Co.[/TD]
[TD]888 Maple St.[/TD]
[TD]Tukwilla[/TD]
[TD]WA[/TD]
[TD="align: right"]98334[/TD]
[/TR]
[TR]
[TD="align: right"]388998[/TD]
[TD]BnB Traders[/TD]
[TD]P.O. Box 7[/TD]
[TD]Anchorage[/TD]
[TD]AK[/TD]
[TD="align: right"]99510[/TD]
[/TR]
[TR]
[TD="align: right"]325463[/TD]
[TD]CC Co.[/TD]
[TD]1243 Made Up Ln.[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98765[/TD]
[/TR]
[TR]
[TD="align: right"]333321[/TD]
[TD]Music World[/TD]
[TD]555 5th Ave.[/TD]
[TD]Edmonds[/TD]
[TD]WA[/TD]
[TD="align: right"]98768[/TD]
[/TR]
[TR]
[TD="align: right"]383009[/TD]
[TD]Pets and Pamper[/TD]
[TD]4787 3rd St.[/TD]
[TD]Kent[/TD]
[TD]WA[/TD]
[TD="align: right"]98366[/TD]
[/TR]
[TR]
[TD="align: right"]520020[/TD]
[TD]Industrial Supply Inc.[/TD]
[TD]88457 54th Ave.[/TD]
[TD]Ballard[/TD]
[TD]WA[/TD]
[TD="align: right"]98444[/TD]
[/TR]
[TR]
[TD="align: right"]500011[/TD]
[TD]Recreational Adventures[/TD]
[TD]232 Easy St.[/TD]
[TD]Seatte[/TD]
[TD]WA[/TD]
[TD="align: right"]98437[/TD]
[/TR]
[TR]
[TD="align: right"]655837[/TD]
[TD]Zip Deliveries[/TD]
[TD]343 4th Ave[/TD]
[TD]Mt. Vernon[/TD]
[TD]WA[/TD]
[TD="align: right"]98876[/TD]
[/TR]
[TR]
[TD="align: right"]299534-B[/TD]
[TD]Green Thumb Landscaping[/TD]
[TD]400 Cherry Dr.[/TD]
[TD]Lynnwood[/TD]
[TD]WA[/TD]
[TD="align: right"]98554[/TD]
[/TR]
</tbody>[/TABLE]