A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Function that sorting rows and paste the result in one cell



 
 
Thread Tools Display Modes
  #1  
Old March 29th, 2004, 02:03 PM
JE McGimpsey
external usenet poster
 
Posts: n/a
Default Function that sorting rows and paste the result in one cell

One way:

=SUMPRODUCT(LARGE($A$1:$F$1,ROW(INDIRECT("1:6"))) *
10^(6-ROW(INDIRECT("1:6"))))


In article ,
stakar wrote:

I have the following columns

A B C D E F
-------------
0 1 2 0 1 1

i need a function that, to sort the data by asceding order and then to
concatenate the result.

So using the above will get the following
G
-------
211100

Is it possible ??
Thanks in advance
Stathis

PS.
If the above is possible, may i have another function too, that
excluding the zeros so to get the

G
-----
2111

instead?

Thanks

  #2  
Old March 29th, 2004, 02:09 PM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Function that sorting rows and paste the result in one cell

Hi
you may try the following user defined function:

Function sort_concatenate(rng As Range)
Dim arr As Variant
Dim holder
Dim ret_str
Dim i
Dim j
arr = rng.Value

For i = LBound(arr, 2) To UBound(arr, 2) - 1
For j = i + 1 To UBound(arr, 2)
If arr(1, i) arr(1, j) Then
holder = arr(1, i)
arr(1, i) = arr(1, j)
arr(1, j) = holder
End If
Next j
Next i

For i = LBound(arr, 2) To UBound(arr, 2)
ret_str = ret_str & arr(1, i)
Next
sort_concatenate = ret_str
End Function

---
if you want zeors included change the last part of this function to
For i = LBound(arr, 2) To UBound(arr, 2)
if arr(1,i) 0 then
ret_str = ret_str & arr(1, i)
end if
Next

--
Regards
Frank Kabel
Frankfurt, Germany

"stakar " schrieb im
Newsbeitrag ...
I have the following columns

A B C D E F
-------------
0 1 2 0 1 1

i need a function that, to sort the data by asceding order and then

to
concatenate the result.

So using the above will get the following
G
-------
211100

Is it possible ??
Thanks in advance
Stathis

PS.
If the above is possible, may i have another function too, that
excluding the zeros so to get the

G
-----
2111

instead?

Thanks


---
Message posted from http://www.ExcelForum.com/


  #3  
Old March 29th, 2004, 02:09 PM
Frank Kabel
external usenet poster
 
Posts: n/a
Default Function that sorting rows and paste the result in one cell


"JE McGimpsey" schrieb im Newsbeitrag
...
One way:

=SUMPRODUCT(LARGE($A$1:$F$1,ROW(INDIRECT("1:6"))) *
10^(6-ROW(INDIRECT("1:6"))))


Hi JE
nice one :-)

Frank

  #4  
Old March 29th, 2004, 03:34 PM
stakar
external usenet poster
 
Posts: n/a
Default Function that sorting rows and paste the result in one cell

Thanks a lot
You both were helpfull!

I was "playing" with both solutions !!

Thanks once more!


---
Message posted from http://www.ExcelForum.com/

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:17 PM.


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