gdougherty
New Member
- Joined
- Sep 30, 2015
- Messages
- 1
We are importing some .CSV files into an Excel file. One column of data (ORDER NUMBER) typically contains NUMBERS (9992570000), the import works fine when this is the case.
However, some data in this column contains ALPHA CHARACTERS within the data (999TX50000); when this scenario occurs this DATA is not imported.
The "row" of data is imported, but this ORDER NUMBER data is dropped.
For example:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]ORDERNUMBER[/TD]
[TD]COL2[/TD]
[TD]COL3[/TD]
[TD]COL4[/TD]
[/TR]
[TR]
[TD]ROW1[/TD]
[TD]9992570000[/TD]
[TD]TEXAS[/TD]
[TD]WABASH[/TD]
[TD]BILL[/TD]
[/TR]
[TR]
[TD]ROW2[/TD]
[TD][/TD]
[TD]IOWA[/TD]
[TD]FRANKFORT[/TD]
[TD]JOE[/TD]
[/TR]
</tbody>[/TABLE]
Appreciate any insight!!
However, some data in this column contains ALPHA CHARACTERS within the data (999TX50000); when this scenario occurs this DATA is not imported.
The "row" of data is imported, but this ORDER NUMBER data is dropped.
For example:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]ORDERNUMBER[/TD]
[TD]COL2[/TD]
[TD]COL3[/TD]
[TD]COL4[/TD]
[/TR]
[TR]
[TD]ROW1[/TD]
[TD]9992570000[/TD]
[TD]TEXAS[/TD]
[TD]WABASH[/TD]
[TD]BILL[/TD]
[/TR]
[TR]
[TD]ROW2[/TD]
[TD][/TD]
[TD]IOWA[/TD]
[TD]FRANKFORT[/TD]
[TD]JOE[/TD]
[/TR]
</tbody>[/TABLE]
Code:
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DefaultDir=\\Omaw2kfile02\lozier\BPA\llcAutoKey;Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;Extensions=txt," _
), Array( _
"csv,tab,asc;FIL=text;MaxBufferSize=2048;MaxScanRows=25;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;" _
)), Destination:=Range("$A$3")).QueryTable
.CommandText = Array( _
"SELECT *" & Chr(13) & "" & Chr(10) & "FROM " & Filename & ".csv " & Filename & "" & Chr(13) & "" & Chr(10))
'MsgBox "SELECT *" & Chr(13) & "" & Chr(10) & "FROM " & Filename & ".csv " & Filename & "" & Chr(13) & "" & Chr(10)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False 'True GD
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_csvFiles"
.Refresh BackgroundQuery:=False
End With
Appreciate any insight!!
Last edited: