+ Reply to Thread
Results 1 to 6 of 6

Cancatenate values on one cell on descending order

Hybrid View

score Cancatenate values on one... 09-26-2015, 09:21 PM
protonLeah Re: Cancatenate values on one... 09-27-2015, 12:25 AM
score Re: Cancatenate values on one... 09-28-2015, 07:27 PM
jason.b75 Re: Cancatenate values on one... 09-27-2015, 11:30 AM
jason.b75 Re: Cancatenate values on one... 09-28-2015, 08:28 PM
score Re: Cancatenate values on one... 09-28-2015, 09:35 PM
  1. #1
    Forum Contributor
    Join Date
    04-22-2011
    Location
    Isabela, Puerto Rico
    MS-Off Ver
    365 Mac Excel Version 16.54
    Posts
    233

    Cancatenate values on one cell on descending order

    I will appreciate if someone may can help me to figure out if is possible to have multiple concatenated values in one cell
    on descending order instead of to the side and wrap
    Eg, January, February, March, April

    I will like to concatenated values in one cell to show like this below
    January
    February
    March
    April
    and so on

    Thanks in advance to anyone who may have a solution for this, thanks very much.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936

    Re: Cancatenate values on one cell on descending order

    Where is the data coming from? If you are manually entering it then just Alt+Enter after each one. If it's via formula, then you will have to post the formula
    (using [CODE][/CODE]) tags.
    Last edited by protonLeah; 09-27-2015 at 12:27 AM.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    04-22-2011
    Location
    Isabela, Puerto Rico
    MS-Off Ver
    365 Mac Excel Version 16.54
    Posts
    233

    Re: Cancatenate values on one cell on descending order

    Hi jason.b75, thanks for your response Im. using a UDF code with array formula to retrieve the desire values on the array i identify each desire values with the asterisk ***
    see code below and array underneath, thanks for taking a look, may you can help me with this
    Function StringConcat(Sep As String, ParamArray Args()) As Variant
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' StringConcat
    ' By Chip Pearson, chip@cpearson.com, www.cpearson.com
    '                  www.cpearson.com/Excel/stringconcatenation.aspx
    ' This function concatenates all the elements in the Args array,
    ' delimited by the Sep character, into a single string. This function
    ' can be used in an array formula. There is a VBA imposed limit that
    ' a string in a passed in array (e.g.,  calling this function from
    ' an array formula in a worksheet cell) must be less than 256 characters.
    ' See the comments at STRING TOO LONG HANDLING for details.
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim S As String
    Dim N As Long
    Dim M As Long
    Dim R As Range
    Dim NumDims As Long
    Dim LB As Long
    Dim IsArrayAlloc As Boolean
    
    '''''''''''''''''''''''''''''''''''''''''''
    ' If no parameters were passed in, return
    ' vbNullString.
    '''''''''''''''''''''''''''''''''''''''''''
    If UBound(Args) - LBound(Args) + 1 = 0 Then
        StringConcat = vbNullString
        Exit Function
    End If
    
    For N = LBound(Args) To UBound(Args)
        ''''''''''''''''''''''''''''''''''''''''''''''''
        ' Loop through the Args
        ''''''''''''''''''''''''''''''''''''''''''''''''
        If IsObject(Args(N)) = True Then
            '''''''''''''''''''''''''''''''''''''
            ' OBJECT
            ' If we have an object, ensure it
            ' it a Range. The Range object
            ' is the only type of object we'll
            ' work with. Anything else causes
            ' a #VALUE error.
            ''''''''''''''''''''''''''''''''''''
            If TypeOf Args(N) Is Excel.Range Then
                '''''''''''''''''''''''''''''''''''''''''
                ' If it is a Range, loop through the
                ' cells and create append the elements
                ' to the string S.
                '''''''''''''''''''''''''''''''''''''''''
                For Each R In Args(N).Cells
                    If Len(R.Text) > 0 Then
                        S = S & R.Text & Sep
                    End If
                Next R
            Else
                '''''''''''''''''''''''''''''''''
                ' Unsupported object type. Return
                ' a #VALUE error.
                '''''''''''''''''''''''''''''''''
                StringConcat = CVErr(xlErrValue)
                Exit Function
            End If
        
        ElseIf IsArray(Args(N)) = True Then
            '''''''''''''''''''''''''''''''''''''
            ' ARRAY
            ' If Args(N) is an array, ensure it
            ' is an allocated array.
            '''''''''''''''''''''''''''''''''''''
            IsArrayAlloc = (Not IsError(LBound(Args(N))) And _
                (LBound(Args(N)) <= UBound(Args(N))))
            If IsArrayAlloc = True Then
                ''''''''''''''''''''''''''''''''''''
                ' The array is allocated. Determine
                ' the number of dimensions of the
                ' array.
                '''''''''''''''''''''''''''''''''''''
                NumDims = 1
                On Error Resume Next
                Err.Clear
                NumDims = 1
                Do Until Err.Number <> 0
                    LB = LBound(Args(N), NumDims)
                    If Err.Number = 0 Then
                        NumDims = NumDims + 1
                    Else
                        NumDims = NumDims - 1
                    End If
                Loop
                On Error GoTo 0
                Err.Clear
                ''''''''''''''''''''''''''''''''''
                ' The array must have either
                ' one or two dimensions. Greater
                ' that two caues a #VALUE error.
                ''''''''''''''''''''''''''''''''''
                If NumDims > 2 Then
                    StringConcat = CVErr(xlErrValue)
                    Exit Function
                End If
                If NumDims = 1 Then
                    For M = LBound(Args(N)) To UBound(Args(N))
                        If Args(N)(M) <> vbNullString Then
                            S = S & Args(N)(M) & Sep
                        End If
                    Next M
                    
                Else
                    ''''''''''''''''''''''''''''''''''''''''''''''''
                    ' STRING TOO LONG HANDLING
                    ' Here, the error handler must be set to either
                    '   On Error GoTo ContinueLoop
                    '   or
                    '   On Error GoTo ErrH
                    ' If you use ErrH, then any error, including
                    ' a string too long error, will cause the function
                    ' to return #VALUE and quit. If you use ContinueLoop,
                    ' the problematic value is ignored and not included
                    ' in the result, and the result is the concatenation
                    ' of all non-error values in the input. This code is
                    ' used in the case that an input string is longer than
                    ' 255 characters.
                    ''''''''''''''''''''''''''''''''''''''''''''''''
                    On Error GoTo ContinueLoop
                    'On Error GoTo ErrH
                    Err.Clear
                    For M = LBound(Args(N), 1) To UBound(Args(N), 1)
                        If Args(N)(M, 1) <> vbNullString Then
                            S = S & Args(N)(M, 1) & Sep
                        End If
                    Next M
                    Err.Clear
                    M = LBound(Args(N), 2)
                    If Err.Number = 0 Then
                        For M = LBound(Args(N), 2) To UBound(Args(N), 2)
                            If Args(N)(M, 2) <> vbNullString Then
                                S = S & Args(N)(M, 2) & Sep
                            End If
                        Next M
                    End If
                    On Error GoTo ErrH:
                End If
            Else
                If Args(N) <> vbNullString Then
                    S = S & Args(N) & Sep
                End If
            End If
            Else
            On Error Resume Next
            If Args(N) <> vbNullString Then
                S = S & Args(N) & Sep
            End If
            On Error GoTo 0
        End If
    ContinueLoop:
    Next N
    
    '''''''''''''''''''''''''''''
    ' Remove the trailing Sep
    '''''''''''''''''''''''''''''
    If Len(Sep) > 0 Then
        If Len(S) > 0 Then
            S = Left(S, Len(S) - Len(Sep))
        End If
    End If
    
    StringConcat = S
    '''''''''''''''''''''''''''''
    ' Success. Get out.
    '''''''''''''''''''''''''''''
    Exit Function
    ErrH:
    '''''''''''''''''''''''''''''
    ' Error. Return #VALUE
    '''''''''''''''''''''''''''''
    StringConcat = CVErr(xlErrValue)
    End Function
    =StringConcat(", ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$F$5:$F$42,""),StringConcat("  ***  ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$E$3,""),StringConcat(", ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$I$5:$I$42,""),StringConcat("  ***  ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$H$3,""),StringConcat(",  ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$L$5:$L$42,""),StringConcat("  ***  ",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$K$3,"")))))))

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Cancatenate values on one cell on descending order

    If you're using a formula then use CHAR(10) as your delimiter.
    If you're using vba then use vbCrLf as your delimiter.

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Cancatenate values on one cell on descending order

    It would be easier to just enter the character into the formula.

    I've not used that code before but I'm going to assume that it works the same way as Harlan Grove's Aconcat function, here's a short example formula using an extract from your huge formula in the previous post.

    =StringConcat("",IF('Men Rank Placement Record'!$C$5:$C$42='Men''s Pics Profile'!$E$3,'Men Rank Placement Record'!$F$5:$F$42&CHAR(10),""))

    Note that I've used a null string for the separator and joined the line feed CHAR(10) to the end of the 'value if true' part of the IF function.

    You will need to apply the 'Wrap text' format to the cells with the formula for it to work.

  6. #6
    Forum Contributor
    Join Date
    04-22-2011
    Location
    Isabela, Puerto Rico
    MS-Off Ver
    365 Mac Excel Version 16.54
    Posts
    233

    Re: Cancatenate values on one cell on descending order

    Thank you very much, this solved my thread , but instead i had to use CHAR(13) for MAC, cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Formula to Rank Values in Descending Order
    By brent_excel in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-16-2015, 07:44 PM
  2. Validate if values associated with the same part number are in descending order
    By forbesk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2014, 03:47 PM
  3. Replies: 5
    Last Post: 05-29-2014, 11:55 AM
  4. Replies: 3
    Last Post: 04-19-2013, 03:07 PM
  5. [SOLVED] Rank values in descending order with duplicates
    By mcain1981 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-14-2012, 01:15 PM
  6. Sorting in descending order and show duplicate values
    By cceze in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-19-2012, 09:33 AM
  7. Replies: 14
    Last Post: 04-17-2012, 05:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1