Filter importing cvs file?

Is there a method where I can filter an importing/updating cvs file?
I have multiple users and would like to only import thier data from the cvs.
The data has been imported to an excel and it refreshes from there.
Who is Participating?
MS Query is from DataFrom other Sources > MS Query
Then you can point it at csv files.
Patrick MatthewsCommented:
Can you post a more complete description of what you need to do, as well as (sanitized) samples of the CSV and Excel files?
Euro5Author Commented:
Each user has a copy of the same file that imports the same csv file.
However, what I need is for the file to only import the number entered in cell C1.
This number would correspond to column A in csv file.

Is this enough description? Thanks so much!
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Yes you can.
If you open up MS Query and use this to open up the csv file you can use SQL to select the data you want... the below code is modified from recorded MS Query...

Dim cmd As String
Dim src As String
Dim dsp As String

    dsp = "txt_" & Format(Now(), "hhmmss")
    src = "ODBC;DefaultDir=" & ThisWorkbook.Path & ";Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;FIL=text;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;"
    cmd = "SELECT *" & Chr(13) & "" & Chr(10) & "FROM `filename.csv` `filename`" & Chr(13) & "" & Chr(10) & "WHERE (filename.Fieldname =  'SearchCriteria')"

    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=src, Destination:=Range("$A$1")).QueryTable
        .CommandText = cmd
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .ListObject.DisplayName = dsp
        .Refresh BackgroundQuery:=False
    End With

Open in new window

to extract a single value:

strPath = ThisWorkbook.Path & "\"

Set cn = CreateObject("ADODB.Connection")
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended Properties=""text;HDR=Yes;FMT=Delimited"";"
cn.Open strcon
Dim rs As Recordset
Dim rsARR() As Variant

Set rs = cn.Execute(strSQL)
thevalue = rs("Region").value
set cn = nothing

Open in new window

Euro5Author Commented:
How do I open up MS Query?
Euro5Author Commented:
Thanks so much!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.