I have a txt file fromated like this:
"SORKOD";"BE0010";"BE0020";"BE0030"
"DEPO_000001";"";"5720004850313864";"266653"
"DEPO_000002";"";"5720004850356083";"278173"
"DEPO_000003";"";"5720004850346091";"286179"
Because it is a large database to open, I wanted to import a filtered table. Used the following code, but it imports only the first column, and don't know why.
Sub GetMyTXTData()
Dim xlcon As ADODB.Connection
Dim xlrs As ADODB.Recordset
Set xlcon = New ADODB.Connection
Set xlrs = New ADODB.Recordset
Dim currentDataFilePath As String
Dim currentDataFileName As String
Dim nextRow As Integer
currentDataFilePath = "K:\TB\"
currentDataFileName = "698"
xlcon.Provider = "Microsoft.ACE.OLEDB.12.0"
xlcon.ConnectionString = "Data Source=" & currentDataFilePath & ";" & "Extended Properties=""text;HDR=NO;FMT=Delimited(,);"""
xlcon.Open
xlrs.Open "SELECT * FROM [" & currentDataFileName & ".txt] WHERE F1='DEPO_000001'", xlcon
xlrs.MoveFirst
nextRow = 4
Sheets(1).Rows(nextRow & ":" & Sheets(1).Rows.Count).Delete
Sheets(1).Cells(nextRow, 1).CopyFromRecordset xlrs
xlrs.Close
xlcon.Close
Set xlrs = Nothing
Set xlcon = Nothing
End Sub