writing a small array to a single cell as a string
Sub Tester3()
Dim aStr As String
Dim myarray()
myarray = Array("10", "12", "10", "12")
Dim i As Variant
aStr = myarray(1)
For i = LBound(myarray) + 1 To UBound(myarray)
aStr = aStr & " " & myarray(i)
Next i
Range("A1").Value = aStr
End Sub
Alan Beban
green fox wrote:
I've been knocking my head against the desk for a few days about
this... probably due more to my inexperience than the difficulty of the
problem. I have a small (variable size )array and I want to write it to
a single cell as a string. Like this
10 12 10 12
I'm seeing lot's of things about turning stuff into arrays, but haven't
found anything I can adapt to going the other way. Here's my code:
Sub Tester3()
Dim aStr As String
Dim myarray(3)
myarray = Array("10", "12", "10", "12")
Dim i As Variant
For i = LBound(myarray) To UBound(myarray)
sStr = myarray(i) & ", " & IIf(aStr = "", "", ", ") & i.Value
Next i
Debug.Print (aStr)
I got the sStr - myarray... from something T. Ogilvy suggested for a
different, but to me similar problem. I get an error saying I need an
object. I know I need to concatenate the values, but what am I missing?
(besides decent knowledge;-)
a.j. fox
|