Combine 3 columns, but keep on separate rows

sjors86

New Member
Joined
Apr 19, 2018
Messages
1
I can't figure out how and if I can combine text from three different columns and place them in the same column, but in same row, I prefer an function.

Example:

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
Guest 1Guest 1Guest 2
Jan van Dam
Erik van DamMarlieke Groot
Chris GrootNadine Vermeer
Joost van Dam

<colgroup><col style="width: 100px"><col width="100"><col width="100"></colgroup><tbody>
</tbody>


Wanted result:

<style type="text/css"><!--td {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}--></style>
Guests
Jan van Dam
Erik van Dam
Marlieke Groot
Chris Groot
Nadine Vermeer
Joost van Dam

<colgroup><col style="width: 100px"></colgroup><tbody>
</tbody>
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
31,930
Office Version
365
Platform
Windows
Hi & welcome to MrExcel.
How about
Code:
Sub CopyToOneCol()
   Dim Ary As Variant, Tmp() As Variant
   Dim UsdRws As Long
   Dim i As Long, j As Long, k As Long
   
   With ActiveSheet
      UsdRws = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
      Ary = .Range("A2:C" & UsdRws).Value
      .Range("A2:C" & UsdRws).ClearContents
      For i = LBound(Ary, 1) To UBound(Ary, 1)
         For j = LBound(Ary, 2) To UBound(Ary, 2)
            If Not Ary(i, j) = "" Then
               ReDim Preserve Tmp(k)
               Tmp(k) = Ary(i, j)
               k = k + 1
            End If
         
         Next j
      Next i
      .Range("A2").Resize(UBound(Tmp) + 1).Value = Application.Transpose(Tmp)
   End With
End Sub
 

Forum statistics

Threads
1,081,441
Messages
5,358,694
Members
400,508
Latest member
fish31

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top