How To Concatenate Multiple Excel Cells In A Column Into One Cell Using VBA.

Опубликовано: 02 Октябрь 2024
на канале: Ctrl-Shift-Run
2,016
18

In this video, we look at how to concatenate multiple cells in a column into a single cell. This is particularly useful when you want to combine multiple sentences into a single paragraph and then copy it to a word document.

The code is as follows:

Sub Concatenate()
Dim wb As Workbook
Set wb = ThisWorkbook

Dim ws As Worksheet
Set ws = wb.Sheets("Sheet1")

Dim sentence As String

For i = 1 To 4
sentence = sentence & " " & ws.Cells(i, 1)
Next i

ws.Cells(1, 2) = Trim(sentence)
End Sub