LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Convert CSV Files to XLS

Myrna:

Code worked great!

Oink!

SowBelly

On Fri, 30 Jul 2004 20:27:32 -0500, Myrna Larson
wrote:

I don't have your files to try it, but I think this should work correctly. YOu
said 1300 files, but 29 * 110 is 3190, so some combinations must be missing.
The code will handle that. Note that the new file is named the same, but with
extension XLS. If there's already a file by that name, it's deleted before the
new one is saved.

Option Explicit

Sub ConvertCSVFiles()
Dim xx As Long
Dim zz As Long
Dim BaseName As String
Dim CSVName As String
Dim XLSName As String

For xx = 1 To 29
For zz = 1 To 110
BaseName = Format$(xx, "00") & "n" & Format$(zz, "00")
CSVName = BaseName & ".csv"

If Len(Dir$(CSVName)) Then
Workbooks.Open Filename:=CSVName
XLSName = BaseName & ".xls"

'delete existing XLS file with this name
If Len(Dir$(XLSName)) Then Kill XLSName

With ActiveWorkbook
.SaveAs Filename:=XLSName, FileFormat:=xlNormal
.Close False
End With
End If
Next zz
Next xx
End Sub


On Fri, 30 Jul 2004 18:05:53 -0400, SowBelly wrote:

Hello:

I have approximately 1300 .csv files that I need to convert to .xls
files so I can extract data from a master spreadsheet. Excel
apparently requires a .csv file be open to extract the data.

I could open each one individually and do a save as, but that would be
rather tedious. Is there a way to programmatically do this. The .csv
files are in the following format:

xxnzz.csv whe

xx is 01-29 (notice the leading 0)
n is n
zz is 01-110 (notice the leading 0 on 1 digit numbers and that the
highest number is 3 digits, 2 digit numbers have no leading 0 i.e.
21n99.

"Pigs can't be humans, but humans can be Pigs!"

Eating at the trough of life.

Oink!

SowBelly




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I batch convert 97-2003 .xls files to 2007 .xlsx files Dave Nuttall Excel Discussion (Misc queries) 4 August 3rd 09 11:38 PM
Convert Multiple CSV Files to XLS Files (Again) Dave Excel Discussion (Misc queries) 1 July 11th 07 04:43 PM
converter tool to convert XL 2007 files to XL 2003 files Dave F Excel Discussion (Misc queries) 6 December 15th 06 12:45 AM
Can I convert my Quatro Pro files to MS Excel files? James HW New Users to Excel 3 May 11th 06 04:42 PM
convert 400 word files to excel files fast? CPower[_13_] Excel Programming 1 June 21st 04 10:29 AM


All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"