Hi,
I have a text file from which I'm locating a string as 'Name "$' and reading third line from then which is expected to be 'Default "$'. Double quote is a part of the string that I'm searching for. Please note that both the strings occur n number of times and I have to read them all and write to a worksheet with all 'Name "$' in col 1 and 'Default "$' in col 2. For every occurrence of 'Name "$', I have to read the 3rd line. I have the code below,
fn = "testfile.txt"
delim = vbTab
temp = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To UBound(x) + 1, 1 To 100)
For i = 0 To UBound(x)
If InStr(1, x(i), "INSTALLATION", 1) > 0 Then
For ii = 0 To 2
n = n + 1: y = Split(x(i + ii), delim)
For iii = 0 To UBound
a(n, iii + 1) = y(iii)
Next
Next
End If
If n > 0 Then
Sheets(1).Cells(1,1).Resize(n, 100).Value = a
Any help here?
I have a text file from which I'm locating a string as 'Name "$' and reading third line from then which is expected to be 'Default "$'. Double quote is a part of the string that I'm searching for. Please note that both the strings occur n number of times and I have to read them all and write to a worksheet with all 'Name "$' in col 1 and 'Default "$' in col 2. For every occurrence of 'Name "$', I have to read the 3rd line. I have the code below,
fn = "testfile.txt"
delim = vbTab
temp = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
x = Split(temp, vbCrLf)
ReDim a(1 To UBound(x) + 1, 1 To 100)
For i = 0 To UBound(x)
If InStr(1, x(i), "INSTALLATION", 1) > 0 Then
For ii = 0 To 2
n = n + 1: y = Split(x(i + ii), delim)
For iii = 0 To UBound
a(n, iii + 1) = y(iii)
Next
Next
End If
If n > 0 Then
Sheets(1).Cells(1,1).Resize(n, 100).Value = a
Any help here?