Another Excel macro question

steveo275

New Member
Joined
Feb 28, 2012
Messages
6
Hello,

I've asked about something similar before here:

Excel Macro question.

I have a similar request. The last one worked great. However, I tried to figure out the macro and how to expand it but it's a bit beyond me.

I need my "Header" sheet:

Header

*ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
1Ref KeyTypeCustomerRef TypeNumberPOTotalCurrencySales TypeRef DateDue DateTermsShip To NameAdd1Add2Add3CityStateZipCountryPhoneFaxBilltoBTAdd1BTAdd2BTAdd3BTCityBTStateBTZipBTCountryBTPhoneBTFaxDiscountTaxSales LocNotesStationRelatedRep1Rep2PeriodYearExemptExempt IDExchg Rate
21000H888888IN1000*100*Invoice1/1/20122/1/2012*********************00CAP*****72012Yes00
32000H488080IN2000*100*Invoice1/1/20122/1/2012*********************00CAP*****72012Yes00

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

To find and match each "ref key" on the "Trailer" sheet:

Trailer

*ABCDEFGHIJKLMNOPQRSTU
1Ref KeyTypeCustomerRef TypeNumberSeqQtyUMProductPriceTaxProduct NameProduct DescriptionDetailAdjstExt PriceCostReturn CodeShip LocSales LocAgent
21000I888888IN100011Case10001100No***010050*CAPCAP88888
31000I888888IN100011Case10002100No***010050*CAPCAP88888
42000I488080IN200021Case10001100No***010050*CAPCAP88888
52000I488080IN200021Case10002100No***010050*CAPCAP88888

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

And create a new sheet called "Results" that looks like this. So, its saying for each header record "ref key" (ex: 1000) find each trailer record "ref key" with the same number (1000) and then copy the header row exactly and put the each matching trailer row under it.

Results

*ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARAS
11000H888888IN1000*100*Invoice1/1/20122/1/2012*****************************72012Yes00
21000I888888IN100011Case10001100No***010050*CAPCAP88888************************
31000I888888IN100011Case10002100No***010050*CAPCAP88888************************
42000H488080IN2000*100*Invoice1/1/20122/1/2012*****************************72012Yes00
52000I488080IN200021Case10001100No***010050*CAPCAP88888************************
62000I488080IN200021Case10002100No***010050*CAPCAP88888************************

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

The columns have to remain as is. The program I'm importing this data with is looking for a certain amount of columns. Thanks again.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
from FAQ

  • Make sure you are in the correct forum for the question you are asking.
  • Word your questions clearly.
  • ALWAYS state what version of Excel and Windows you are using (i.e., Excel 97, Windows XP, etc.)
  • Don't use a subject line like HELP ME! or EXCEL question. Instead, say something like Trouble With Pivot Tables In XL97. And remember, saying URGENT doesn't make it so to anyone but you.
  • Provide background information for your question when needed. Include example data and formulas in your post. The more you tell us up front, the easier it is for us to answer your questions. If your formulas aren't giving the results you want, include the results you want to get, as well as the results you're getting. Your post should include at least:
 
Upvote 0
My sincerest apologies to the board for not reading the FAQ. I'm sure this has devastated the MrExcel community. I'm not sure how I'm going to sleep at night knowing the pain my subject has caused all of you. We must put this travesty behind us and look forward. It's the only way the healing process can begin.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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