I am trying to take a variant variable and convert it into a string so that I can run a split function on the data. However, whenever I try to redefine the variant I get a type mismatch error. I have used the CStr(), Str(), and ToString functions. None work.
Anything I am missing?
Function FlatLine(ByVal lines As Variant)
Dim flat() As String
ReDim Preserve flat(i)
For i = 0 To UBound(lines)
flat(UBound(flat)) = lines(i)
ReDim Preserve flat(LBound(flat) To UBound(flat) + 1)
Next i
Dim flat2 as String
flat2 = Cstr(flat)
^ errors there.
flatis array of strings,flat2is string. How are you going to convert array of strings to string? 2) why not just useReDim flat(0 To UBound(lines))?flat(i) = lines(i)in your loop and remove lineReDim Preserve flat(LBound(flat) To UBound(flat) + 1). So,the end game after this is to take this new string and run a split.- what new string?flatis array of strings, but not single string. You can't convert array of string to single string.