Good morning, follow the code. Just select the first row of the columns you want to concatenate. Run with two columns only.
Option Explicit
Sub concatena_colunas()
Dim coluna_01 As Long
Dim coluna_02 As Long
Dim linha As Long
On Error GoTo sair:
'Armazena e coloca em ordem crescente
coluna_01 = Selection.Areas(1).Column
If Selection.Areas(2).Column < coluna_01 Then
coluna_02 = Selection.Areas(1).Column
coluna_01 = Selection.Areas(2).Column
Else
coluna_02 = Selection.Areas(2).Column
End If
linha = ActiveCell.Row
Do
Cells(linha, coluna_01).Value = Cells(linha, coluna_01).Value & " " & Cells(linha, coluna_02).Text
linha = linha + 1
Loop While Cells(linha, coluna_01).Value <> Empty
coluna_01 = 0
coluna_02 = 0
linha = 0
sair:
End Sub
Unfortunately the code did not work for me, I modified the values there at the end of the coluna_01 and coluna_02 and line for the ones I use, but nothing happened. I must change something else?
– user145161
No need to change the code, just select the first row of each column you want to concatenate. I edited the answer by adding a figure.
– Paulo Vieira
Thank you! I managed to make it work, but unfortunately I’m trying to join two columns, a date and a time, the date is copied without problem, but the time is all disfigured, even changing the type of column to date+time. Got any tips on how to fix this?
– user145161
I changed the code, see if it works, here it worked.
– Paulo Vieira
It worked perfectly, thank you so much for your help !
– user145161