excel vba read txt file with commas

  Heefie 19:35 26 Jan 05

Why do I always want to do such seemingly easy, but apparently not, things ?!?!?!

In the following (simplified) code, I am reading through a TXT file that I do not want to update, just extract data from :

Dim MyDataRec as String

Dim MyCash as String

Do While Not EOF(1)

Input #1, MyDataRec

If Left$(MyDataRec, 7) = "Manager" Then

MyCash = Mid$(MyDataRec, 35, 20)

End If


Close #1

The data that I want to pick up for MyCash, in position 35, has commas in it, so the input record (frustratingly !!!) terminates at that point ... therefore if position 35 contains, for example :

"CASH : £345,678,99"

... then MyCash is set to "CASH : £345"

So ... the obvious question is, how do I get the whole txt line read in, commas included, as data ?!?

  VoG II 20:19 26 Jan 05

Does click here help.

If you specify something other than "," as Sep this approach should work.

  Heefie 11:43 06 Feb 05

... it diddn't help at first, but I just couldn't see the wood for the trees .

I've looked up every web site in Chritendom, so it seems, but I could never find anyhting clear cut, then it hit me ... there is the word LINE before the INPUT command in these examples you sent me to, I just couldn't see it, I was looking for parameters and delimiters AFTER the INPUT command ... DOH !!!

So to summarise for anybody with a similar problem :

Input #1, MyDataRec << delimts input at commas

Line Input #1, MyDataRec << dives you the whole line

This thread is now locked and can not be replied to.

Nintendo Switch (Nintendo NX) release date, price, specs and preview trailer: Codename NX console…

1995-2015: How technology has changed the world in 20 years

8 things designers (and brands) need to know about the modern woman

How to speed up a slow Mac: 19 great tips to make an iMac, MacBook or Mac mini run faster | Speed…