Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub GetMyCSVData()
- 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 = "C:\Users\thaobt.acc\Desktop\"
- currentDataFileName = "CreCSSV"
- xlcon.Provider = "Microsoft.Jet.OLEDB.4.0"
- xlcon.ConnectionString = "Data Source=" & currentDataFilePath & ";" & "Extended Properties=""text;HDR=Yes;FMT=Delimited;"""
- xlcon.Open
- xlrs.Open "SELECT Voucher,Quantity,Price,Total FROM [" & currentDataFileName & ".csv] WHERE Price > 200", xlcon
- xlrs.MoveFirst
- nextRow = Worksheets("Sheet3").UsedRange.Rows.Count + 1
- Worksheets("Sheet3").Cells(nextRow, 1).CopyFromRecordset xlrs
- xlrs.Close
- xlcon.Close
- Set xlrs = Nothing
- Set xlcon = Nothing
- End Sub
Add Comment
Please, Sign In to add comment