Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Get data from a CSV file

Hello everybody,

Thank you very much for helping us and teaching us so many tricks. I learn
vba thanks to you !

My problem :
I have got several .csv files with data.
When I open one of these files in Excel, the data (that I need) is in row R
and column C.
Now, knowing R and C, I want to get this specific data for the other .csv
files without opening them.

Currently, I use this program:
Dim strFileToLoad As String
Dim aContent() As Variant
Dim lngRowNb As Long
Dim lngColumnNb As Long
Dim lngFa As Long
Dim lngRow As Long
Dim lngColumn As Long
Dim vInputData As Variant

lngFa = FreeFile
Open strFileToLoad For Input As #lngFa
For lngRow = 1 To lngRowNb
For lngColumn = 1 To lngColumnNb
Input #lngFa, vInputData
aContent(lngRow, lngColumn) = vInputData
Next lngColumn
Next lngRow
Close

Then, my data is in aContent(R, C).

NB:
* aContent(R, C) is typically a string or a number with no fix number of
characters/figures.
* I do not need the full aContent array just aContent(R, C).

Is there another way? An easier way? A faster way?
Could I use FileSystemObject or VBScript, anywhere?

Thank you.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Get data from a CSV file


Thank you. You are correct. By the way, your proposal is what I am doing
currently. But it is soooooooo slow...
Nothing faster anyone ?


"jaf" a écrit dans le message de news:
...
Hi,
Input will see both the comma and CR as a delimiter.
If your .csv has 6 fields, 5 commas and one CR, then you need 6 inputs to
get one row.

So if you want the data in the 15th row and 4th column. Then 14*6=84 plus

4
(88) will be the target data.
(14 full rows and another 4 columns)

lngFa = FreeFile
Open strFileToLoad For Input As #lngFa
InputNb=88
For lngRow = 1 To lnputNb

Input #lngFa, vInputData


Next lngRow

debug.print vInputData 'the last one read
Close



--

John

johnf202 at hotmail dot com


"Neo2" wrote in message
...
Hello everybody,

Thank you very much for helping us and teaching us so many tricks. I

learn
vba thanks to you !

My problem :
I have got several .csv files with data.
When I open one of these files in Excel, the data (that I need) is in

row
R
and column C.
Now, knowing R and C, I want to get this specific data for the other

..csv
files without opening them.

Currently, I use this program:
Dim strFileToLoad As String
Dim aContent() As Variant
Dim lngRowNb As Long
Dim lngColumnNb As Long
Dim lngFa As Long
Dim lngRow As Long
Dim lngColumn As Long
Dim vInputData As Variant

lngFa = FreeFile
Open strFileToLoad For Input As #lngFa
For lngRow = 1 To lngRowNb
For lngColumn = 1 To lngColumnNb
Input #lngFa, vInputData
aContent(lngRow, lngColumn) = vInputData
Next lngColumn
Next lngRow
Close

Then, my data is in aContent(R, C).

NB:
* aContent(R, C) is typically a string or a number with no fix number of
characters/figures.
* I do not need the full aContent array just aContent(R, C).

Is there another way? An easier way? A faster way?
Could I use FileSystemObject or VBScript, anywhere?

Thank you.








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
import data from txt file to an existing excel file shaji Excel Discussion (Misc queries) 1 September 12th 09 04:15 PM
Link from Chart File to Data File / Format Problem Brad Bross Charts and Charting in Excel 0 July 31st 08 10:15 PM
To get client data from a saved file back to the master file Darmac54 Excel Discussion (Misc queries) 0 August 18th 05 03:29 AM
How do I reference external data from a file, file name found in . Clux Excel Discussion (Misc queries) 1 February 10th 05 10:52 PM
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 07:47 AM.

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

About Us

"It's about Microsoft Excel"