Forum Discussion
Jyggalag77
Aug 11, 2022Copper Contributor
Conditionally merge cells based on number?
Hi all, I want my cell to be merged like this (see attached photo). What defines my data is that there is always an age, so I would like to have, for example, a formula where once a number en...
- Aug 11, 2022
Sub merge() Dim i As Long Dim x As Variant Dim result As String Dim k As Long Dim m As Long Range("B:B").Clear m = Range("A" & Rows.Count).End(xlUp).Row k = 3 For i = 3 To m x = Right(Cells(i, 1), 1) If IsNumeric(x) Then Cells(k, 2).Value = Trim(result & " " & Cells(i, 1).Value) k = k + 1 result = "" Else result = Trim(result & " " & Cells(i, 1).Value) End If Next i End Sub
Maybe with this code. In the attached file you can click the button in cell D2 to run the macro.
NikolinoDE
Aug 11, 2022Gold Contributor
=A3&", "&B3&", "&C3