Hi Team,
Hopefully you can help me
I am trying to concatenate cells from activecell to lastrow but the thing is VBA code "LastRow" go to the last cell with data and there are some cells as empty between them so I leave an image about my expectation in green and yellow highlited is the one that is working with my VBA Code Below.
Sub Concatenate()
Lastrow = Worksheets("Data").Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
Dim Result As String
Dim sepr As String
Dim b As String
sepr = "-"
Worksheets("Data").Select
For i = ActiveCell.Row To Lastrow
b = Cells(i, ActiveCell.Column).Value
Result = Result & b & sepr
Next i
Result = Left(Result, Len(Result) - Len(sepr))
ActiveCell.Offset(0, 1).Value = Result
End Sub
Appreciate your response
Hopefully you can help me
I am trying to concatenate cells from activecell to lastrow but the thing is VBA code "LastRow" go to the last cell with data and there are some cells as empty between them so I leave an image about my expectation in green and yellow highlited is the one that is working with my VBA Code Below.
Sub Concatenate()
Lastrow = Worksheets("Data").Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row
Dim Result As String
Dim sepr As String
Dim b As String
sepr = "-"
Worksheets("Data").Select
For i = ActiveCell.Row To Lastrow
b = Cells(i, ActiveCell.Column).Value
Result = Result & b & sepr
Next i
Result = Left(Result, Len(Result) - Len(sepr))
ActiveCell.Offset(0, 1).Value = Result
End Sub
Appreciate your response