C
christophercbrewster via OfficeKB.com
I need to pass information from one thing to another as a tabbed table in a
TXT file, then convert that to an array. I have it working, but the vbCr
character caused (IMHO) more trouble than it should have:
1. I used SPLIT to convert the file's text content to a 1-D array, each cell
being a row of the table. Since the delimiter character is vbCr, I would
expect the array cells NOT to include the character, but they do. I tried
REPLACE(array(i), vbCr, "") in various places but couldn't get rid of it.
2. In a loop I used SPLIT again on each row cell, using vbTab as the
delimiter. The tab dropped out of the array, but of course the vbCr's were
still there. To make this worse, the array including vbCr's is treated as an
error-- any statement referring to it fails.
3. I'd expect the vbCr's to appear at the end of the last cell in each row,
but they're at the start of the first cell of each row-- EXCEPT the first row.
So I added code to find the length of each first cell and chop the first
character, with a special condition to exclude cell(0,0).
I assume many tabbed tables have needed to be converted to arrays. My
solution is klugy and seems likely to cause errors at some later date. Is
there a way around the vbCr problem?
TXT file, then convert that to an array. I have it working, but the vbCr
character caused (IMHO) more trouble than it should have:
1. I used SPLIT to convert the file's text content to a 1-D array, each cell
being a row of the table. Since the delimiter character is vbCr, I would
expect the array cells NOT to include the character, but they do. I tried
REPLACE(array(i), vbCr, "") in various places but couldn't get rid of it.
2. In a loop I used SPLIT again on each row cell, using vbTab as the
delimiter. The tab dropped out of the array, but of course the vbCr's were
still there. To make this worse, the array including vbCr's is treated as an
error-- any statement referring to it fails.
3. I'd expect the vbCr's to appear at the end of the last cell in each row,
but they're at the start of the first cell of each row-- EXCEPT the first row.
So I added code to find the length of each first cell and chop the first
character, with a special condition to exclude cell(0,0).
I assume many tabbed tables have needed to be converted to arrays. My
solution is klugy and seems likely to cause errors at some later date. Is
there a way around the vbCr problem?