read an arbitrary line

blue333

Board Regular
Joined
Mar 19, 2009
Messages
64
Hi everyone

I am writing an excel macro which needs to be able to read an arbitrary line from a text file. Suppose the text file contained the following text where each of the sentences is on a separate line:

This is line 1
This is line 2
This is line 3
This is line 4

I need to be able to select an arbitrary line to read. If I can store each line as an array element then I am done but I don't know how to do that. How can I store each line as an array element?

Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
thanks for the reply Blade Runner. I used that code but replaced the file path. I ran the code and I got a "Input past end of file (Error 62)" error. The file is a html file but I am treating it as a text file so I can read arbitrary lines. Any idea why I am getting the error message?
 
Upvote 0
Hi,

Would importing the html file as a data connection be acceptable?
If so, you can use the "From Web" option, but instead of inputting a web address, use for example file:///C:/example.html

That way you can manipulate the data with all standard excel functions

I hope this helps
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,033
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top