Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading values from a txt file

Status
Not open for further replies.

ajpalm

Technical User
Dec 12, 2001
1
AU
I'm using VBa in excel, and wondering if there is a way to read a txt file values in.

eg

I wish to read the 2nd line of a file, and store its value as a varabile within the vba project?

Any ideas?
 
dim sFile as string
dim sLine as string
dim sSecondLineFromFile as string
dim nFile as integer

nFile=freefile

open sFile for input as nFile
line input #nFile, sLine ' reads first line
line input #nFile, sLine ' reads second line
close nFile

sSecondLineFromFile=sLine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top