View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob van Gelder[_4_] Rob van Gelder[_4_] is offline
external usenet poster
 
Posts: 1,236
Default Convert String of 512 numbers to a range

Kevin,

This converts to rows as columns max out at 256
First bit puts a string together, second bit strips it apart.

Sub test()
Const cSeparator = ","
Dim str512 As String, i As Long, j As Long

'build it
str512 = ""
For i = 0 To 512 - 1
str512 = str512 & IIf(str512 = "", "", cSepChar & " ") & Int(Rnd() *
900 + 100)
Next

'strip it
With Sheet1
i = 1: j = InStr(1, str512, cSeparator)
Do Until j = 0
.Cells(i, 1) = Trim(Mid(str512, 1, j - 1))
str512 = Mid(str512, j + Len(cSeparator))
i = i + 1
j = InStr(1, str512, cSeparator)
Loop
If Len(Trim(str512)) 0 Then Cells(i, 1) = Trim(str512)
End With
End Sub


Rob


"Kevin G" wrote in message
news:v0ZRb.29750$A7.8532@edtnps84...
Hello,

How would I convert a single cell string consiting of 512 values: 545,

565,
576, etc... to a range of 512 cells.

Thanks, Kevin Graham