View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
L.Mathe L.Mathe is offline
external usenet poster
 
Posts: 24
Default User Select File on Import External Data

Using Excel 2003. I am importing data into a ws and applying filters to it
to use elsewhere. How can I have the query run so the user can select the
file to be imported? The file name is always the same, it is the directory &
sub directory that will be different each day. What I have so far is:

Sub ImportData()
'
Sheets("Import").Select

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;F:\2010\January\Jan31\COOP\dscdc004.rtf" ,
Destination:=Range("A1")) <---------this line is the problem - need to
select file
.Name = "dscdc004"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 172
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 9, 1, 9, 1, 9)
.TextFileFixedColumnWidths = Array(19, 74, 4, 47, 13)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Columns("A:C").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="WD"
Selection.AutoFilter Field:=3, Criteria1:="399.99", Operator:=xlAnd, _
Criteria2:="<485.00"
End Sub

Any help is apprectiated
--
Linda