Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Importing Text File Based on Query
I have a CSV File which I want to import into my spreadsheet. I hav
included the file in this posting. I use the following code below to pull in the entire file. It work great. It creates separate columns for the data items based on comm delimited logic. I want to update the code so that I can enter a quer based on the items in column 1, 3 and 4. Column 1 has either "Offers or "Bids" data. Note they are continuous. Column 3 has "date" data and column 4 has "Hour" data (1-24). I want to be able to query o only the "Offers", for a given day in column 3 (ie. 01/01/2004) for given hour in column 4. How do I do this? Sub ImportRange1() Set ImpRng = ActiveCell Open "c:\Documents an Settings\rkaczanowski.EDCASSOCIATES\Desktop\Histor ical_Trading_2004_01.CSV _ For Input As #1 r = 0 c = 0 txt = "" Application.ScreenUpdating = True Do While Not EOF(1) Line Input #1, VData For i = 1 To Len(VData) char = Mid(VData, i, 1) If char = "," Or i = Len(VData) Then ActiveCell.Offset(r, c) = txt c = c + 1 txt = "" Else If char < Chr(34) Then _ txt = txt & Mid(VData, i, 1) End If Next i c = 0 r = r + 1 Loop Close #1 Application.ScreenUpdating = True End Su Attachment filename: historical_trading_2004_01.txt Download attachment: http://www.excelforum.com/attachment.php?postid=57349 -- Message posted from http://www.ExcelForum.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Build a query from a web-based database or a PDF file. | Excel Discussion (Misc queries) | |||
Importing CSV file (saved as Text) into XL as Text -- over 60 colu | Excel Discussion (Misc queries) | |||
Importing text file, only option to edit existing file | Excel Discussion (Misc queries) | |||
Importing Text file based on criteria | Excel Discussion (Misc queries) | |||
importing text file, removing data and outputting new text file | Excel Programming |