Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default String to Range?

Hi again, I have already posted help on this but I can't get it to work. I
would like try again.
Thanks to Tom Ogilvy I can convert a Range of cells (J9:J520) to a single
cell string. (See code below)

Sub RangeToArray()
'Tom Ogilvy creator
Dim sStr As String
Dim cell As Range
sStr = ""
For Each cell In Range("J9:J520")
sStr = sStr & cell.Value & ", "
Next
sStr = Left(sStr, Len(sStr) - 2)
ActiveCell.Value = sStr
End Sub

I now need to convert this single cell string back to the cell range
(J9:J520). The converted single cell string will have 512 values and may
consist of 2, 3 or 4 digit values. Example: 598, 593, 1002, 598, 565, 98,
etc...

Is this possible? How can it be done?

Thanks, Kevin Graham




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default String to Range?

Kevin,

Try something like the following. Change the value of the
variable S to the actual string containing the data values.

Dim S As String
Dim Arr As Variant
S = "1,2,3"
Arr = Split(S, ",")
Range("J9:J520").Value = Application.Transpose(Arr)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Kevin G" wrote in message
news:KjSSb.3026$7O2.909@edtnps89...
Hi again, I have already posted help on this but I can't get it

to work. I
would like try again.
Thanks to Tom Ogilvy I can convert a Range of cells (J9:J520)

to a single
cell string. (See code below)

Sub RangeToArray()
'Tom Ogilvy creator
Dim sStr As String
Dim cell As Range
sStr = ""
For Each cell In Range("J9:J520")
sStr = sStr & cell.Value & ", "
Next
sStr = Left(sStr, Len(sStr) - 2)
ActiveCell.Value = sStr
End Sub

I now need to convert this single cell string back to the cell

range
(J9:J520). The converted single cell string will have 512

values and may
consist of 2, 3 or 4 digit values. Example: 598, 593, 1002,

598, 565, 98,
etc...

Is this possible? How can it be done?

Thanks, Kevin Graham






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplication of string values within a range JRD Excel Worksheet Functions 4 June 26th 09 07:24 PM
Return a String in a 7 Row Range Q Sean Excel Worksheet Functions 6 October 6th 08 03:36 PM
convert a string to range? JK Excel Worksheet Functions 4 June 20th 06 01:04 AM
Convert String of 512 numbers to a range Kevin G[_2_] Excel Programming 10 February 2nd 04 06:02 AM
Converting a range to string Robert Stober Excel Programming 1 October 3rd 03 09:39 PM


All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"