Macro Help: 6 Sets of Addresses in single row --> Export to new workbook, each address on a new sheet preceded by the data in columns A-D

jeffcoleky

Active Member
Joined
May 24, 2011
Messages
274
Example files, click to download:
1. ExportMe.xlsm
2. Exported.xlsm

My post is quite long but don't be intimidated by it. The macro I need hopefully will be fairly easy for someone here, I just couldn't figure it out.

Objective: I'm trying to export several rows of data to a new worksheet. Each person/row has 6 addresses and I want to split the address types into new sheets in the same file. I also need the first 4 four cells of each line to be repeated prior to the address.

A step-by-step explanation:
  1. User selects ANY cell range within "c:\dropbox\ExportMe.xlsm"
  2. For each row of selected data, macro copies the following data into the first 8 columns of a new workbook "c:\dropbox\Exported.xlsm", and in their own respective sheet.
Sheet 1
a. Column A
b. Column B
c. Column C
d. Column D
e. Column E
f. Column F
g. Column G
h. Column H
Sheet 2
a. Column A
b. Column B
c. Column C
d. Column D
e. Column I
f. Column J
g. Column K
h. Column L
Sheet 3
a. Column A
b. Column B
c. Column C
d. Column D
e. Column M
f. Column N
g. Column O
h. Column P
Sheet 4
a. Column A
b. Column B
c. Column C
d. Column D
e. Column Q
f. Column R
g. Column S
h. Column T
Sheet 5
a. Column A
b. Column B
c. Column C
d. Column D
e. Column U
f. Column V
g. Column W
h. Column X
Sheet 6
a. Column A
b. Column B
c. Column C
d. Column D
e. Column Y
f. Column Z
g. Column AA
h. Column AB

BEFORE:
1. ExportMe.xlsm - Excel 2010

ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
Primary AddressSecond AddressThird AddressFourth AddressFifth AddressSixth Address
First NameLast NameField3ValueStreetCityStateZipStreetCityStateZipStreetCityStateZipStreetCityStateZipStreetCityStateZipStreetCityStateZip
BrianWayYes12116 Saint Clair DrMooresvilleNC2053 JOHNSON RDLOUISVILLEKY5406 Gaskin CtLouisvilleKY10421 Martinside DrMooresvilleNC10719 Allen DrFairdaleKY1216 Lexington RdLouisvilleKY
Andy & PamelaJonesNo8102 Kerry RdMooresvilleNC6303 GOALBY DRLOUISVILLEKY4309 Seagrape RdJeffersontownKY4030 Mapleton AveMooresvilleNC11710 Lower River RdLouisvilleKY5200 Benson CtLouisvilleKY
MelyssaHarrodYes5109 Garden Green WayMooresvilleNC6602 AUDRY WAY UNIT 104LOUISVILLEKY2124 Dogoon DrLouisvilleKY5504 Westhall AveMooresvilleNC13927 Fancy GapJeffersontownKY7600 Aspen Ridge RdLouisvilleKY
YvonneWebbNo815 Bluegrass AveMooresvilleNC4951 S 3Rd StLouisvilleKY7411 Arapaho DrMooresvilleNC3927 Pinoak View CtJeffersontownKY10603 Back Run RdJeffersontownKY

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]$110,380 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40245[/TD]

[TD="align: right"]40229[/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40118[/TD]

[TD="align: right"]40204[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]$89,880 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40258[/TD]

[TD="align: right"]40299[/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40207[/TD]

[TD="align: right"]40272[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]$242,250 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40219[/TD]

[TD="align: right"]40223[/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40299[/TD]

[TD="align: right"]40214[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]$100,430 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"][/TD]

[TD="align: right"]40214[/TD]

[TD="align: right"]28117[/TD]

[TD="align: right"]40299[/TD]

[TD="align: right"]40299[/TD]

</tbody>
Sheet1
So for instance, if someone highlighted any range of cells within rows 3, 4, 5, 6, after the macro is run it would look like this:

AFTER
2. Exported.xlsm - Excel 2010.

ABCDEFGH
First NameLast NameField3ValueStreetCityStateZip
BrianWayYes12116 Saint Clair DrMooresvilleNC
Andy & PamelaJonesNo8102 Kerry RdMooresvilleNC
MelyssaHarrodYes5109 Garden Green WayMooresvilleNC
YvonneWebbNo815 Bluegrass AveMooresvilleNC

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]$110,380 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]$89,880 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]$242,250 [/TD]

[TD="align: right"]28117[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]$100,430 [/TD]

[TD="align: right"]28117[/TD]

</tbody>
Sheet1
ABCDEFGH
First NameLast NameField3ValueStreetCityStateZip
BrianWayYes2053 JOHNSON RDLOUISVILLEKY
Andy & PamelaJonesNo6303 GOALBY DRLOUISVILLEKY
MelyssaHarrodYes6602 AUDRY WAY UNIT 104LOUISVILLEKY

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]$110,380 [/TD]

[TD="align: right"]40245[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]$89,880 [/TD]

[TD="align: right"]40258[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]$242,250 [/TD]

[TD="align: right"]40219[/TD]

[TD="align: center"][/TD]

[TD="align: right"][/TD]

[TD="align: right"][/TD]

</tbody>
Sheet2
ABCDEFGH
First NameLast NameField3ValueStreetCityStateZip
BrianWayYes5406 Gaskin CtLouisvilleKY
Andy & PamelaJonesNo4309 Seagrape RdJeffersontownKY
MelyssaHarrodYes2124 Dogoon DrLouisvilleKY
YvonneWebbNo815 BLUEGRASS AVELOUISVILLEKY

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]$110,380 [/TD]

[TD="align: right"]40229[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]$89,880 [/TD]

[TD="align: right"]40299[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]$242,250 [/TD]

[TD="align: right"]40223[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]$100,430 [/TD]

[TD="align: right"]40215[/TD]

</tbody>
Sheet3
And so forth with Sheets 4, 5, 6...

**NOTE: Sometimes there are empty address fields. If so please skip it.

Does this make sense and if so, can someone help me out with a macro please? If not, please ask and i'll do my best to clarify.

Thanks -Jeff

 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Was this too complicated? All i need is to know how to export specified columns to a new workbook and in separate sheets. Please help!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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