Save a range of cells to a file

gseymour

New Member
Joined
Dec 1, 2012
Messages
18
Hello,
I am trying to save a portion of a worksheet to a .csv file keeping the same format that is on the original worksheet (ie date formatted mm-dd-yyyy, etc for each column). To start a .csv file is imported to the worksheet and column formatting (insert/delete/move) is done at that time. The input file can vary in row length from file to file but columns are the same 7. I want the range to be captured from a4, lastCol 7 to lastRow, lastCol 7. Most of the columns are text and number but one is a date that has to be mm-dd-yyyy format. I need the output file to be .csv with the data starting in a1 and formatted to keep the already formatted data the same from the original worksheet. Can anyone provide sample code for this?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Well... I finally have code that will export the data to a .csv file but I have two issues. First one is a column is formatted as a date field mm-dd-yyyy in the original file but it is showing as ,#yyyy-mm-dd#, when I view the .csv file and I need it to be ,"mm-dd-yyyy",. I need the correct format and # signs removed. Is there a way to keep the same format? Second issue is a column that has all negative numbers in the original file and I need to have all of the numbers as positives with no $ or commas in the exported .csv file. Can anyone help me?
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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