+ Reply to Thread
Results 1 to 2 of 2

Getting a table and combining comments

Hybrid View

  1. #1
    Registered User
    Join Date
    04-12-2019
    Location
    Dallas
    MS-Off Ver
    2016
    Posts
    64

    Getting a table and combining comments

    Hello,

    I'm trying to figure out how to combined strings that meet certain criteria. I have a table that holds comments from users and I want to be able to have the answers from one person and concatenate them into one cell. I included an example of what I'm trying to figure out.

    Name Greetings Comment
    Bill Morning Hello People
    Rachel Morning Hi
    Bill Morning Welcome
    Bill Afternoon Good Bye
    Susan Afternoon Bye


    With the table above, I want to be able to grab all the rows that include: Name and Greeting with the comment associated with them. I want to be able to grab Bill and Morning with the comment that was said. It would look like:

    Bill Morning Hello People Welcome

    So It would grab Bill and Morning and combined the two comments that were said.

  2. #2
    Registered User
    Join Date
    04-12-2019
    Location
    Dallas
    MS-Off Ver
    2016
    Posts
    64

    Re: Getting a table and combining comments

    I figured out how to solve my problem. I ended up using VBA instead of a function. If anyone is also trying to do the same thing I have posted my code below:

    Sub GetResponses()
        Dim RA As String
        Dim Words As String
        Dim FRow As Integer
        Dim FindRA As String
        Dim FindRM As String
        Dim y As Integer, z As Integer, b As Integer, c As Integer, a As Integer
        Dim RM As String  
        Dim Row1 As Long 
        Dim Words2 As String
        Dim WordsCombined As String
        Dim Col As String
        Dim ColumnNumber As Long
        Dim RowResp As Integer
        
        Worksheets("Survey Data").Activate
        
        Row1 = Sheets("Survey Data").Cells(Rows.Count, "A").End(xlUp).Row + 1   'This will show the last column with data
        
        a = 2
        RA = Worksheets("Survey Scores").Range("B5")
        y = 3
        z = 1
        b = 1
        ColumnNumber = 29
        RowResp = 24
        c = 1
        
    Do Until c = 3
        Col = Split(Cells(1, ColumnNumber).Address, "$")(1)
        Do Until b = 11
            Do Until a = Row1
                RM = Worksheets("Survey Scores").Cells(6, y).Value
                FindRA = Worksheets("Survey Data").Range("K" & a)
                FindRM = Worksheets("Survey Data").Range("H" & a)
                
                If FindRA = RA And FindRM = RM Then
                    Worksheets("Survey Data").Range("K" & a).Select
                    FRow = ActiveCell.Row
                    Words = Worksheets("Survey Data").Range(Col & FRow).Value
                    If Words <> "" And Words <> "N/A" Then
                        Words2 = z & ": " & Words & "     "
                        WordsCombined = WordsCombined & Words2
                        z = z + 1
                    End If
                    a = a + 1
                Else
                    a = a + 1
                End If
            Loop
            
            Worksheets("Survey Scores").Cells(RowResp, y) = WordsCombined
            WordsCombined = ""
            a = 2
            z = 1
            y = y + 2
            b = b + 1
        Loop
    c = c + 1
    y = 3
    ColumnNumber = ColumnNumber + 3
    RowResp = RowResp + 1
    b = 1
    Loop
    
    Worksheets("Survey Scores").Activate
    End Sub

    This code find 2 variable (one of the variable changes after the first loop) and if there is a match it grabs the cell and put it into a variable and will continue to grow till the loop is finished. I reset the variable after each loop.

+ 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. Pivot table - Comments
    By mbj1701 in forum Excel General
    Replies: 1
    Last Post: 09-18-2019, 11:44 AM
  2. Pivot Table with Comments
    By nickytraps in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2019, 11:38 AM
  3. Problem combining comments from different cells to another cell with vba
    By lairscah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2014, 02:15 AM
  4. Combining comments
    By Gcam85 in forum Excel General
    Replies: 2
    Last Post: 04-25-2013, 10:09 AM
  5. Can I add table to a comments box ?
    By Soon Swee Fong in forum Excel General
    Replies: 1
    Last Post: 10-18-2012, 05:23 AM
  6. Excel 2007 : Comments in Pivot table
    By dacamedic in forum Excel General
    Replies: 0
    Last Post: 06-16-2011, 05:13 PM
  7. Pivot Table - With Comments Outside the Table
    By G20EGG in forum Excel General
    Replies: 2
    Last Post: 01-27-2008, 03:38 PM

Tags for this Thread

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