Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I batch convert 97-2003 .xls files to 2007 .xlsx files | Excel Discussion (Misc queries) | |||
Convert Multiple CSV Files to XLS Files (Again) | Excel Discussion (Misc queries) | |||
converter tool to convert XL 2007 files to XL 2003 files | Excel Discussion (Misc queries) | |||
Can I convert my Quatro Pro files to MS Excel files? | New Users to Excel | |||
convert 400 word files to excel files fast? | Excel Programming |