G
Guest
I used split to convert a csv file into a string array. Everything works
fine until I've a file with empty lines in between and when I run the split
function, my program will give an error "Script out of range" as long as it
hits the blank line. How can I overcome this? Is the empty line causing the
problem ? My script is as below
Open filename For Input As #1
x = 0
m = 1
z = a + b
w = 0
For n = 1 To w
Line Input #1, strline
arrstring = Split(strline, ",")
Worksheets("384-template").Range("B1").Offset(x + z, 0).Value =
arrstring(1){Debug stops here}
Worksheets("384-template").Range("C1").Offset(x + z, 0).Value =
arrstring(2)
Worksheets("384-template").Range("D1").Offset(x + z, 0).Value =
arrstring(0)
x = x + 48
m = m + 1
If m > 8 Then
m = 1
x = 0
z = z + 2
End If
'Debug.Print n, x, z, x + z, m
Next n
Close #1
Thanks!
fine until I've a file with empty lines in between and when I run the split
function, my program will give an error "Script out of range" as long as it
hits the blank line. How can I overcome this? Is the empty line causing the
problem ? My script is as below
Open filename For Input As #1
x = 0
m = 1
z = a + b
w = 0
For n = 1 To w
Line Input #1, strline
arrstring = Split(strline, ",")
Worksheets("384-template").Range("B1").Offset(x + z, 0).Value =
arrstring(1){Debug stops here}
Worksheets("384-template").Range("C1").Offset(x + z, 0).Value =
arrstring(2)
Worksheets("384-template").Range("D1").Offset(x + z, 0).Value =
arrstring(0)
x = x + 48
m = m + 1
If m > 8 Then
m = 1
x = 0
z = z + 2
End If
'Debug.Print n, x, z, x + z, m
Next n
Close #1
Thanks!