Losing column formatting when copying worksheet to new workbook.

foolios

New Member
Joined
Aug 4, 2011
Messages
21
Attempting to do:
I have a macro enabled workbook(.xlsm) with 2 sheets that are filled in by a third sheet.
I want those 2 sheets to be saved as .csv files separately from each other
and the original workbook so that I can upload them to a database.

So far:
Through VBA code I have found that I can't simply save the worksheets but that each sheet has to be moved to a new workbook then saved.
That feature works.

The problem:
The formatting of columns as text and custom to preserve leading zeros
is lost from the original worksheet to the moved to worksheet.

Question:
How do I keep all the column formatting during the sheet's transition to the
new workbook for saving?

Thank you so much in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
By the way:
I keep reading that sheets have to be moved to a new workbook before they
can be saved but I realized I've been using this code block below all along without issue and
it does basically just that; exports the worksheet directly as a .pdf without being moved to a new workbook.

Why can this be done with .pdf's or is there a way that I haven't read
about to do this with sheets themselves to .csv ???

Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:="***.pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, OpenAfterPublish:=False
Thanks for your time.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
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