+ Reply to Thread
Results 1 to 3 of 3

Macro - Complex Concatenate

Hybrid View

quintans1 Macro - Complex Concatenate 04-24-2014, 12:04 PM
millz Re: Macro - Complex... 04-24-2014, 12:24 PM
quintans1 Re: Macro - Complex... 04-24-2014, 12:43 PM
  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    12

    Macro - Complex Concatenate

    The data pull I receive on a month to month basis never has the columns in the same order.

    I would like to know how to write a macro that will look for the columns I want to concatenate and then concatenate them in the first available column in my spreadsheet.

    I have attached a spreadsheet where I would like the columns "Rate your experience?" and "On a scale of 0 to 10, how did it go?" to be concatenated into a new column, named "Rating - ALL".

    I am new to macros and haven't got beyond recording a macro for a simple concatenate. So any help would be appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Macro - Complex Concatenate

    Hello, try running this macro. I assume you know how to put it into a module.
    Sub FindAndConcatenate()
        Dim i, RateYrExpCol, ScaleCol As Long
        For i = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
            Select Case True
                Case Cells(1, i).Value Like "*Rate your exp*"
                    RateYrExpCol = i
                Case Cells(1, i).Value Like "*On a scale*"
                    ScaleCol = i
            End Select
        Next
        If RateYrExpCol = 0 Or ScaleCol = 0 Then
            MsgBox "Couldn't find all columns!"
            Exit Sub
        End If
        With Cells(1, Columns.Count).End(xlToLeft).Offset(, 1)
            .Value = "Rating - ALL"
            With .Offset(1).Resize(Range("A1").CurrentRegion.Rows.Count - 1)
                .Formula = "=" & Cells(.Row, RateYrExpCol).Address(0, 0) & "&" & Cells(.Row, ScaleCol).Address(0, 0)
                .Value = .Value
            End With
        End With
    End Sub
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    05-16-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Macro - Complex Concatenate

    That worked, thank you.

+ 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] Slightly complex Concatenate with IFS - help appreciated!!
    By twigdip in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-08-2013, 07:38 AM
  2. Complex Macro Help
    By MrDuck1984 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2011, 06:37 PM
  3. Complex Macro Help
    By rmiranda1824 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2011, 11:17 AM
  4. complex macro
    By sukhi_01 in forum Excel General
    Replies: 2
    Last Post: 05-16-2008, 06:17 AM
  5. complex macro
    By sukhi_01 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2008, 12:06 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