Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi there.
I have a column of values, which is interspersed with empty cells, that typically looks like the following: red green blue yellow black purple orange How can I build a string that looks like the following? red,green,blue,yellow,black,purple,orange Any ideas? - greatly appreciated. Geoff |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
with code?
Sub BringTogether() Dim rng as Range, cell as Range Dim s as String set rng = Columns(1).SpecialCells(xlConstants,xlTextValues) for each cell in rng s = s & trim(cell.Value) & "," Next s = Left(s,len(s)-1) msgbox s End Sub -- Regards, Tom Ogilvy wrote in message ups.com... Hi there. I have a column of values, which is interspersed with empty cells, that typically looks like the following: red green blue yellow black purple orange How can I build a string that looks like the following? red,green,blue,yellow,black,purple,orange Any ideas? - greatly appreciated. Geoff |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom
Thankyou for your response to my problem. From my past experiences with you I know that the solution that you offer is very eloquent. However, I think the solution to my problem lays with a function. To this end I have taken your code and tried to modify it. Unfortunately that is not working too well either. The following is my attempt so far: What I am trying to do, is run the function with a named range (("colJ") as a parameter. Function BringTogether(rng) As Range Dim rng As Range, cell As Range Dim s As String '----Set rng = Columns(J).SpecialCells(xlConstants, xlTextValues) Set rng = rng.SpecialCells(xlConstants, xlTextValues) For Each cell In rng s = s & Trim(cell.Value) & "," Next BringTogether = Left(s, Len(s) - 1) End Function Regards Geoff Tom Ogilvy wrote: with code? Sub BringTogether() Dim rng as Range, cell as Range Dim s as String set rng = Columns(1).SpecialCells(xlConstants,xlTextValues) for each cell in rng s = s & trim(cell.Value) & "," Next s = Left(s,len(s)-1) msgbox s End Sub -- Regards, Tom Ogilvy wrote in message ups.com... Hi there. I have a column of values, which is interspersed with empty cells, that typically looks like the following: red green blue yellow black purple orange How can I build a string that looks like the following? red,green,blue,yellow,black,purple,orange Any ideas? - greatly appreciated. Geoff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Building criteria string for Advanced Filter variable not resolvin | Excel Discussion (Misc queries) | |||
Building Sum by Matching String | Excel Discussion (Misc queries) | |||
Help building string for Names.Add RefersTo, pls? | Excel Programming | |||
Building a String based on Selected Check boxes | Excel Programming | |||
building a text string while looping though a worksheet | Excel Programming |