Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading/Disassembling a String of information
The code below gathers numbers from a set range and then consolidates
them to one cell: E F G ... V 1 No 3 ... 1,No,3,... Sub StrgGen() Set nana = Range("E12:T12") Range("V12").ClearContents increment = 1 For Each c1 In nana If increment = 1 Then Range("V12").Value = c1.Value increment = 2 Else Range("V12").Value = Range("V12").Value & "," & c1.Value End If Next c1 End Sub I am curious to know if there is a way to disassemble the generated string. The values of the cells are not restricted and thus the string will vary in length. Does anyone have any solutions? Any help will be greatly appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading/Disassembling a String of information
Hi,
Open the Visual Basic Editor, type SPLIT, place your cursor anywhere in the word and press F1. Also do the same for JOIN. These are very useful commands for working with strings and they make it much easier to read in and write out strings stored in memory. Hope this helps. "mastermind" wrote: The code below gathers numbers from a set range and then consolidates them to one cell: E F G ... V 1 No 3 ... 1,No,3,... Sub StrgGen() Set nana = Range("E12:T12") Range("V12").ClearContents increment = 1 For Each c1 In nana If increment = 1 Then Range("V12").Value = c1.Value increment = 2 Else Range("V12").Value = Range("V12").Value & "," & c1.Value End If Next c1 End Sub I am curious to know if there is a way to disassemble the generated string. The values of the cells are not restricted and thus the string will vary in length. Does anyone have any solutions? Any help will be greatly appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading/Disassembling a String of information
Thank you for the information, but I still need some help. I don't
really know what to put in the expression segment of the code. Do you think that you could give me an example. Using the criteria given in the initial problem statement. Split(0, "," , -1) = Range("T13:E13") Is what I tried and it doesn't work, probably for obvious reasons, but if you could help me out with an example or further explaination that would be great. Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Reading/Disassembling a String of information
First off, Split is a function and, as such, operates on something... you
can't assign anything to it. Second, it takes a single String argument and produces an array with each element of the array containing the text occurring between the delimiters, so you would want to give it V13 to operate on, no E13:T13. Third, you didn't tell us what you wanted to do with the disassembled values. Here is some code which will put the disassembled information on Row 25 starting in Column A... Sub Test() Dim X As Long Dim Parts() As String Parts = Split(Range("V13").Value, ",") For X = 0 To UBound(Parts) Range("A25").Offset(0, X).Value = Parts(X) Next End Sub Rick "mastermind" wrote in message ... Thank you for the information, but I still need some help. I don't really know what to put in the expression segment of the code. Do you think that you could give me an example. Using the criteria given in the initial problem statement. Split(0, "," , -1) = Range("T13:E13") Is what I tried and it doesn't work, probably for obvious reasons, but if you could help me out with an example or further explaination that would be great. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
retrieve information from clipboards not in the reading pane | Excel Discussion (Misc queries) | |||
Newbie: Reading color information | Excel Programming | |||
Reading information from a closed workbook | Excel Programming | |||
Reading the Clipboard Source Information | Excel Programming | |||
Reading information from all workbooks in a folder... | Excel Programming |