Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Select File on Import External Data

Oops. I see that extra ( in the .getopenfilename line (now!).

RTF extensions usually indicate that it's some sort of Rich Text Format (a file
option in MSWord).

There's usually other junk in that type of file besides data.

If you made the .rtf extention, you may want to be careful with your selection.

L.Mathe wrote:

THANK YOU, it works! Thanks for the heads up to watch for typos, 1 minor
correction was done.

I had seen your website with this VBA, but didn't know how to work it into
mine. And, yep, it is a .rtf file. There is a huge .csv file (125 columns,
35,000 rows) that generates 4 reports. I only need one of the reports (with
fewer columns) to accomplish my task.

Thank you again for your help. Very much appreciated.
--
Linda

"Dave Peterson" wrote:

You're really importing an RTF file??

Dim myFilename as variant
....more code
myfilename = application.getopenfilename((filefilter:="RTF Files,*.rtf")

if myfilename = false then
'user hit cancel
exit sub
end if

With ActiveSheet.QueryTables.Add(Connection:="TEXT;" _
& myfilename, Destination:=activesheet.Range("A1"))
....


(Untested, uncompiled. Watch for typos.)




L.Mathe wrote:

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


--

Dave Peterson
.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSV Import - user to select file joecrabtree Excel Programming 1 December 13th 06 02:29 PM
import external data from changing file name nathan Excel Worksheet Functions 2 April 6th 05 04:39 PM
External File Data Import Adam Thickett Excel Programming 3 September 3rd 03 04:03 PM
External File Data Import (F.A.O. Bernie) Adam Thickett Excel Programming 0 September 3rd 03 10:43 AM
Get External Data, Import Text File, File name problem Scott Riddle Excel Programming 1 July 11th 03 05:40 PM


All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"