Results 1 to 4 of 4

Thread: CONCAT into one cell based on 2 values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by Admin View Post
    Code:
       If TypeOf ConcatCol Is Range Then
            If ConcatCol.Columns.Count > 1 And ConcatCol.Rows.Count = 1 Then
                blnTranspose = True
                ConcatCol = Application.Transpose(Application.Transpose(ConcatCol.Value2))
            ElseIf ConcatCol.Columns.Count = 1 And ConcatCol.Rows.Count > 1 Then
                ConcatCol = Application.Transpose(ConcatCol.Value2)
            End If
        End If
        
        For lngLoop = LBound(ParamA) To UBound(ParamA)
            If TypeOf ParamA(lngLoop) Is Range Then
                If blnTranspose Then
                    ParamA(lngLoop) = Application.Transpose(Application.Transpose(ParamA(lngLoop).Value2))
                Else
                    ParamA(lngLoop) = Application.Transpose(ParamA(lngLoop).Value2)
                End If
            End If
        Next
    The following comment is for the red highlighted text, but it also applies (concept-wise) to the blue highlighted text as well. You do not need to use the double Application.Transpose to assign a single row horizontal range of cells as a one-dimensional array to a variable. Here is a more direct way...

    ConcatCol = Application.Index(ConcatCol.Value2, 1, 0)

    Note: The Value or Value2 property must be specified or the code won't work.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Quote Originally Posted by Rick Rothstein View Post
    The following comment is for the red highlighted text, but it also applies (concept-wise) to the blue highlighted text as well. You do not need to use the double Application.Transpose to assign a single row horizontal range of cells as a one-dimensional array to a variable. Here is a more direct way...

    ConcatCol = Application.Index(ConcatCol.Value2, 1, 0)

    Note: The Value or Value2 property must be specified or the code won't work.
    Good point!
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Return a comment based on values in another cell
    By msiyab in forum Excel Help
    Replies: 5
    Last Post: 05-23-2015, 02:47 AM
  2. Replies: 3
    Last Post: 11-22-2013, 08:22 AM
  3. IF STATEMENT BASED ON EQUAL VALUES IN RANGE
    By mrmmickle1 in forum Excel Help
    Replies: 3
    Last Post: 09-09-2013, 05:54 PM
  4. Replies: 2
    Last Post: 05-30-2013, 07:28 PM
  5. Offset based on Values in Column E
    By mrmmickle1 in forum Excel Help
    Replies: 7
    Last Post: 12-04-2012, 10:06 AM

Tags for this Thread

Posting Permissions

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