Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am importing a CSV file and want to be selective in my data. I need to
bypass any record that does not have a char "V" in the specified column. The above subject is also the standard QueryTables.Add statement. Any suggestions? -- Rick Rack |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rick wrote:
I am importing a CSV file and want to be selective in my data. I need to bypass any record that does not have a char "V" in the specified column. The above subject is also the standard QueryTables.Add statement. Any suggestions? Rick: Unless I'm misunderstanding something, you can be selective with a QueryTables.Add statement. You pass a SQL statement to QueryTables.Add and use the SQL statement to limit the records it imports. Here's an example: Sub AddQTFromCSV() Dim sConn As String Dim sSQL As String sConn = "ODBC;DSN=Text Files;" & _ "DefaultDir=C:\Documents and Settings\Dick\My Documents;" & _ "DriverId=27;MaxBufferSize=2048;PageTimeout=5; " sSQL = "SELECT Field1, Field2, Field3, Field4, Field5" & _ " FROM `C:\Documents and Settings\Dick\My Documents`\Book1.csv" & _ " WHERE (Field2='V')" With Sheet3.QueryTables.Add(sConn, Sheet3.Range("A1"), sSQL) .Refresh End With End Sub -- Dick Kusleika MVP - Excel Excel Blog - Daily Dose of Excel www.dicks-blog.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ActiveSheet.QueryTables.Add | Excel Programming | |||
help with ActiveSheet.QueryTables.Add Connection: | Excel Programming | |||
ActiveSheet.QueryTables.Add using a File DSN | Excel Programming | |||
With ActiveSheet.QueryTables.Add | Excel Programming |