Thanks Dan. That helps in part, however, the critical element toward automation is the VBA to get it to cycle to the next file to insert. I can insert one file at the bottom of the spreadsheet but I don't know how to code it to jump to the next file in the directory. I thought about using the file name as a variable, but unfortunately, I don't think the file name will be of much help -- the name is formatted by date, for example, LG123006 = Log Dec. 30, '06. The next file in line is LG123106, not LG123007, so it is difficult to treat them like a list.
Selection.End(xlDown).Sele
RW = ActiveCell.Row
CSVNAME = "LG123006"
CSVFILE = CSVNAME & ".csv"
With ActiveSheet.QueryTables.Ad
"TEXT;C:\FortLogs\2006\" & CSVFILE, _
Destination:=Range(Cells(R
.Name = CSVNAME
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
.TextFileTabDelimiter = False
.TextFileSemicolonDelimite
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumb
.Refresh BackgroundQuery:=False
End With
Main Topics
Browse All Topics





by: xDJR1875Posted on 2007-09-04 at 11:07:52ID: 19827100
What I would do is this. d(Connecti on:="TEXT; C:\importc sv.csv", _ ter = False r = False ers = True xternal Data").Visible = False
1) Separate each year of files into a separate directory.
2) Create a macro of importing one of the files into a spreadsheet. I did this and came up with the following macro for a comma delimited file.
With ActiveSheet.QueryTables.Ad
Destination:=Range("A1"))
.Name = "importcsv"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
.TextFileTabDelimiter = True
.TextFileSemicolonDelimite
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1)
.TextFileTrailingMinusNumb
.Refresh BackgroundQuery:=False
End With
Application.CommandBars("E
3) Create a routine in vba within your macro to cycle through the files and import each one
thanks,
Dan Reynolds