Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi!
I am writing a macro to import certain *.csv files to Excel. Each line in the csv files represents a record. I wish Excel to import the records only if it founds certain keywords. Can anyone suggests me which sets of commands I can use to do the things above? Million thanks!!! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It is really easy to import *all * the records and delete the ones you
do not want. --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The problem is each CSV file consist of over 100,000 records . . .
"BrianB " wrote in message ... It is really easy to import *all * the records and delete the ones you do not want. --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This works well by me :
Sub readFromCSV() Dim oCnn As Object Dim oCat As Object Dim oRs As Object Dim strPath As String, strFileName As String, strSQL As String Set oCnn = CreateObject("ADODB.Connection") Set oRs = CreateObject("ADODB.Recordset") strPath = "D:\" 'this is the path to file strFileName = "a.csv" 'name of the file strSQL = "SELECT * FROM " & strFileName & " WHERE Field1 = 'x'" oCnn.Open _ "Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=" & strPath ";Extensions=asc,csv,tab,txt" oRs.Open strSQL, oCnn With oRs While Not .EOF 'here code for insertion to worksheet '... oRs.movenext Wend End With oRs.Close oCnn.Close End Su -- Message posted from http://www.ExcelForum.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The reason I don't use Access is because I need to do some mathematical
analysis with the data. I also need to filter out some of the unwanted records . . . if I do it manually it will take me at least 1 hr per each of the hundreds CSV files. "BrianB " wrote in message ... <<over 100,000 records MS Access then ? --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selective Validation | Excel Discussion (Misc queries) | |||
Selective on Name | Excel Discussion (Misc queries) | |||
Selective Trendlines | Charts and Charting in Excel | |||
Excel External Data Selective Import. | Excel Discussion (Misc queries) | |||
selective averaging | Excel Worksheet Functions |