How am I to read in a text file in xl if I have spaces in them(see attached gantry_4.txt). I know how to read in them without any spaces(see attached gantry_3.txt). My codes for reading gantry_3.txt is as follows:
PHP Code:
Private Sub GetTT()
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim File As Scripting.File
Dim Sep As String
Dim RowNdx As Integer
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer
Dim file2 As String, file3 As String
Sep = ","
'go to MAPVIEW sheet
Worksheets("Sheet1").Activate
Set fso = New Scripting.FileSystemObject
Set fld = fso.GetFolder("C:\GetTT")
'cycle to each file in the folder
For Each File In fld.Files
'this returns the whole path name of the file
Debug.Print File.Name
'Add the codes to open or do what you need in this text file
Application.ScreenUpdating = False
Since you "Line Input #1, WholeLine" you can split the string on
the "," char. Then Trim on each element. This will remove the
spaces. The Split function returns an array of elements without
the ","s and you can loop through each array element to the
UBound entering the value into each Cell.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
I need to check the 4th line in a text file named parameters.txt. It will b either 0,1,2,3,4,5,6,7 or 8.I have 6 columns of data in Excel.Column A, B,C,D,E,F. I want to check thru the 4th and 5th columns(D,E). If any of the values is more than the num in the text file, I want the WHOLE ROW of data to be deleted and the next row of data to be shifted up in the Sheet.Hope u understand what I mean.Can anyone pls help.? Its urgent.I dunno how to do it.Thanks