VBA concatenate cells

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
128
Hi everyone!

Im looking to concatenate the active cell with the first cell of the column, separated by a coma.

So if active cell is A3 then concatenate A3 with A1, if active cell is B3 then concatenate with B1, if active cell is G30 concatenate with G1, etc

A1= January
Active cell = empty "run macro" active cell = January

B1 = July
Active cell = 7 "run macro" Active cell = 7,July

Any help woud be greatly appreciated
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try:
VBA Code:
Sub M1()

With ActiveCell
  .Value = .value & "," & activesheet.cells(1, .column).value
End With

End Sub
 
Upvote 0
Hi, I have a similar problem where I have first five cells in the row to concatenate but with a - between each, then carry on down the sheet till last row, can this be done with VBA also?
 
Upvote 0
Alternative to VBA is Power Query/Get and Transform. Here is Mcode

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Merged Columns" = Table.CombineColumns(Source,{"Column1", "Column2", "Column3", "Column4", "Column5"},Combiner.CombineTextByDelimiter("-", QuoteStyle.None),"Merged")
in
    #"Merged Columns"
 
Upvote 0
Hi, I have a similar problem where I have first five cells in the row to concatenate but with a - between each, then carry on down the sheet till last row, can this be done with VBA also?
Does this do what you want?

VBA Code:
Sub Textjoin_Values()
  With Range("F2:F" & Range("A" & Rows.Count).End(xlUp).Row)
    .Formula = "=TEXTJOIN(""-"",1,A2:E2)"
    .Value = .Value
  End With
End Sub

20 08 11.xlsm
ABCDEF
1
2adgjma-d-g-j-m
3behknb-e-h-k-n
4cfiloc-f-i-l-o
5
Concat
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,566
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top