Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default Multiple colums into a single cell

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Multiple colums into a single cell

Hi,

I think you are going to need to construct a VBA Function to do that. I'm
working so I can't spend the time now, but I sure someone will write one for
you its not too tough.


--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Tony S." wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default Multiple colums into a single cell

Yeah, I figured I'd probably need some code. That's what I was referring to
when I said "formula". Thanks Shane...

"Shane Devenshire" wrote:

Hi,

I think you are going to need to construct a VBA Function to do that. I'm
working so I can't spend the time now, but I sure someone will write one for
you its not too tough.


--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Tony S." wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Multiple colums into a single cell

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default Multiple colums into a single cell

Excellent Chip, as always.
Question: Since, the exact number of rows can always vary, is it possible to
set the range to a maximun number and not return extra spaces with commas for
blank cells? Like this?

Set RR = Range("A1:A999")

"Chip Pearson" wrote:

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Multiple colums into a single cell

Maybe something like:

Option Explicit
Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
S = ""
For Each R In RR.Cells
If R.Value = "" Then
'skip it
Else
'do the concatenation
S = S & R.Text & ", "
End If
Next R
If S = "" Then
'all blank, so do nothing
Else
S = Left(S, Len(S) - 2)
End If
Range("C1").Value = S
End Sub

Tony S. wrote:

Excellent Chip, as always.
Question: Since, the exact number of rows can always vary, is it possible to
set the range to a maximun number and not return extra spaces with commas for
blank cells? Like this?

Set RR = Range("A1:A999")

"Chip Pearson" wrote:

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!



--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default Multiple colums into a single cell

Thank you Dave. That did the trick. Also, thanks for the remarks in the code
to help me understand.

"Dave Peterson" wrote:

Maybe something like:

Option Explicit
Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
S = ""
For Each R In RR.Cells
If R.Value = "" Then
'skip it
Else
'do the concatenation
S = S & R.Text & ", "
End If
Next R
If S = "" Then
'all blank, so do nothing
Else
S = Left(S, Len(S) - 2)
End If
Range("C1").Value = S
End Sub

Tony S. wrote:

Excellent Chip, as always.
Question: Since, the exact number of rows can always vary, is it possible to
set the range to a maximun number and not return extra spaces with commas for
blank cells? Like this?

Set RR = Range("A1:A999")

"Chip Pearson" wrote:

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Multiple colums into a single cell


Tony,

Replace

Set RR = Range("A1:A10")

with

With Worksheets("Sheet1")
Set RR = Range(.Cells(1, "A"), _
.Cells(.Rows.Count, "A").End(xlUp))
End With

This will set RR to a range from row 1 to the last non-empty cell in
column A.

Replace

S = S & R.Text & ", "

with

If StrComp(R.Text, vbNullString) < 0 Then
S = S & R.Text & ", "
End If

This will skip empty cells.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 12:13:01 -0800, Tony S.
wrote:

Excellent Chip, as always.
Question: Since, the exact number of rows can always vary, is it possible to
set the range to a maximun number and not return extra spaces with commas for
blank cells? Like this?

Set RR = Range("A1:A999")

"Chip Pearson" wrote:

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!


  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 60
Default Multiple colums into a single cell

Fantastic Chip! Both yours and Dave solution work perfectly. I can't thank
you all enough.

"Chip Pearson" wrote:


Tony,

Replace

Set RR = Range("A1:A10")

with

With Worksheets("Sheet1")
Set RR = Range(.Cells(1, "A"), _
.Cells(.Rows.Count, "A").End(xlUp))
End With

This will set RR to a range from row 1 to the last non-empty cell in
column A.

Replace

S = S & R.Text & ", "

with

If StrComp(R.Text, vbNullString) < 0 Then
S = S & R.Text & ", "
End If

This will skip empty cells.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 12:13:01 -0800, Tony S.
wrote:

Excellent Chip, as always.
Question: Since, the exact number of rows can always vary, is it possible to
set the range to a maximun number and not return extra spaces with commas for
blank cells? Like this?

Set RR = Range("A1:A999")

"Chip Pearson" wrote:

Try code like the following:

Sub AAA()
Dim S As String
Dim RR As Range
Dim R As Range

Set RR = Range("A1:A10")
RR.Sort key1:=Range("A1"), order1:=xlAscending
For Each R In RR.Cells
S = S & R.Text & ", "
Next R
S = Left(S, Len(S) - 2)
Range("C1").Value = S
End Sub

This sorts A1:A10 in ascending order and then writes all values as a
single text string into C1. Change ranges to meet your needs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 18 Feb 2009 10:06:06 -0800, Tony S.
wrote:

Is there a formula that can sort multiple cell in order lowest to highest,
then show the result in a single cell oriented horizontally?

I have this:
7
41
13
8
44
14
9
24
38
1
25
2
11
26
3
12
4
22
50
6
23
32
29
40
15
30
in diffenent rows. I'mtrying to get this...
1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 29, 30, 32,
38, 40, 41, 44, 50
in one cell. Each number sepaated by a comma and space.
Thanks!


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
Multiple formats in a single cell with multiple formulas Zakhary Excel Worksheet Functions 1 May 2nd 08 12:08 AM
Multiple hyperlinks in a single cell. Possible? If so, how? John Excel Discussion (Misc queries) 1 April 24th 08 08:33 PM
Is there a way to have colums wrap on a single page Phil Lawson Excel Discussion (Misc queries) 3 September 4th 07 10:35 PM
Multiple hyperlinks in a single cell lorildemarco Excel Discussion (Misc queries) 3 August 7th 06 08:02 PM
Using a single cell in multiple formulas ebethcat Excel Worksheet Functions 1 May 26th 05 02:42 PM


All times are GMT +1. The time now is 07:12 PM.

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

About Us

"It's about Microsoft Excel"