How do I save a CSV file (Comma Separated Value) with VBA in Excel 2000?

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

Below is my file looks like this

AUDCAD D1 (Export generated by OpenClose Data )
DATE,HOUR,CLOSE-OPEN ,HIGH-LOW,HIGH-OPEN,OPEN-LOW
25 May 2016,00:00,6.70,20.50,18.00,2.50
24 May 2016,00:00,-62.50,100.00,13.00,87.00
23 May 2016,00:00,29.30,55.30,49.20,6.10
20 May 2016,00:00,-0.30,46.00,37.50,8.50
19 May 2016,00:00,41.50,74.10,52.10,22.00
18 May 2016,00:00,-34.50,71.40,4.80,66.60
17 May 2016,00:00,56.50,95.20,90.70,4.50
16 May 2016,00:00,16.50,63.30,57.80,5.50
13 May 2016,00:00,-7.00,56.50,8.50,48.00
12 May 2016,00:00,-68.50,106.30,6.30,100.00
11 May 2016,00:00,-21.80,68.90,39.30,29.60
10 May 2016,00:00,17.50,77.10,62.10,15.00

I want after VBA it saves in excel and look as follow


Book1
ABCDEF
1AUDCAD D1 (Export generated by OpenClose Data )
2DATEHOURCLOSE-OPENHIGH-LOWHIGH-OPENOPEN-LOW
325-may-160:006,720,5182,5
424-may-160:00-62,51001387
523-may-160:0029,355,349,26,1
620-may-160:00-0,34637,58,5
719-may-160:0041,574,152,122
818-may-160:00-34,571,44,866,6
917-may-160:0056,595,290,74,5
1016-may-160:0016,563,357,85,5
1113-may-160:00-756,58,548
1212-may-160:00-68,5106,36,3100
1311-may-160:00-21,868,939,329,6
1410-may-160:0017,577,162,115
OpenClose_AUDCAD D1


Thanks In Advance

Regards,
Moti
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hello,

When I open “OpenClose_AUDCAD D1.CSV” file data look like as shown below

AUDCAD D1 (Export generated by OpenClose Data )
DATE,HOUR,CLOSE-OPEN ,HIGH-LOW,HIGH-OPEN,OPEN-LOW
25 May 2016,00:00,6.70,20.50,18.00,2.50
24 May 2016,00:00,-62.50,100.00,13.00,87.00
23 May 2016,00:00,29.30,55.30,49.20,6.10
20 May 2016,00:00,-0.30,46.00,37.50,8.50
19 May 2016,00:00,41.50,74.10,52.10,22.00
18 May 2016,00:00,-34.50,71.40,4.80,66.60
17 May 2016,00:00,56.50,95.20,90.70,4.50
16 May 2016,00:00,16.50,63.30,57.80,5.50
13 May 2016,00:00,-7.00,56.50,8.50,48.00
12 May 2016,00:00,-68.50,106.30,6.30,100.00
11 May 2016,00:00,-21.80,68.90,39.30,29.60
10 May 2016,00:00,17.50,77.10,62.10,15.00

I need to import above file in to workbook excel and save as excel file


Book1
ABCDEF
1AUDCAD D1 (Export generated by OpenClose Data )
2DATEHOURCLOSE-OPENHIGH-LOWHIGH-OPENOPEN-LOW
325-may-160:006,720,5182,5
424-may-160:00-62,51001387
523-may-160:0029,355,349,26,1
620-may-160:00-0,34637,58,5
719-may-160:0041,574,152,122
818-may-160:00-34,571,44,866,6
917-may-160:0056,595,290,74,5
1016-may-160:0016,563,357,85,5
1113-may-160:00-756,58,548
1212-may-160:00-68,5106,36,3100
1311-may-160:00-21,868,939,329,6
1410-may-160:0017,577,162,115
OpenClose_AUDCAD D1


Please help with some VBA to get this done

Regards,
Moti
 
Upvote 0
Hi,
That's exactly how it looks if you open in excel so really it's good already. For information on saving files with vba check out the vba SaveAs function:
Use VBA SaveAs in Excel 2007-2016
xenou , just now I checked file is CSV but it is checked to open with programme excel, it open exactly how it looks
In #post 1 & 2

Yes your suggestion did the trick once file is opened I tried to save as Microsoft excel 2000 it works perfect file saved with *.xls

Thank you for your help

Now I need one more solution I have total 21 total files in one folder is located at desktop under name "Data"
and every day once old files are replaced with new data once so is there any code if I run it, that open all 21 files and save them as Microsoft excel
instead it doing manually one by one?

Regards,
Moti
 
Upvote 0
Hi, I'd suggest opening a new thread for the last since I won't be able to help you with that in a timely manner. If you want to try it, the short answer is to use some functions for handling files to open workbooks and then save them using saveas. You may need to add some code to do something with the old files. This would all involve a loop over all the files in the folder. And you can probably run it from a "master workbook" in another folder (although it could also be written as a VBScript script).
ξ
 
Upvote 0
Hi, I'd suggest opening a new thread for the last since I won't be able to help you with that in a timely manner. If you want to try it, the short answer is to use some functions for handling files to open workbooks and then save them using saveas. You may need to add some code to do something with the old files. This would all involve a loop over all the files in the folder. And you can probably run it from a "master workbook" in another folder (although it could also be written as a VBScript script).ξ
Thank you xenou, i will open a new thread

Regards,
Moti
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,231
Members
449,091
Latest member
jeremy_bp001

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