Excel 2003 - VBA code to read .txt file

  Heefie 18:53 05 Jul 2008
Locked

Hi, Any help appreciated ... I can read and process a .txt file from my Excel VBA program, but I am having trouble when I read certain lines ...

The file I am reading contains a number of heading lines, followed by a number of data lines.

All of the data lines (the only ones I am interested in) should end in a date (DD/MM), but occasionally they (the format of this .txt file is out of my control, BTW) have what I assume is a "Tab" character after the MM, which means that my code to find lines with a numeric at the end, does not recognise the last character as being numeric.

If I place the cursor at the end of a data line that has this problem and press backspace, all characters at the end are deleted (it looks like 3 characters), so they are not individual spaces) ...

Can somebody please suggest a way around this ?!?

  VoG II 19:10 05 Jul 2008

You are more likely to get a response to your thread on MrExcel click here

I have to go out now but I would suggest testing whether the last character in a line of text is a Tab (vbTab) and if it is then apply your test to the penultimate character.

  Heefie 20:45 05 Jul 2008

... and they've sorted it, thanks ...

If anybody cares, this is the code :

MyEndChar = Right(MyDSRec, 1)

If Asc(MyEndChar) = 9 Then
MyDSRec = Left(MyDSRec, (Len(MyDSRec) - 1))
End If

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

Elsewhere on IDG sites

WPA2 hack: How secure is your Wi-Fi?

Add Depth Of Field to a photo using Tilt Shift Blur in Photoshop

iPhone tips & tricks

Comment afficher des fichiers cachés sur Mac ?