Day 11 VBA Hero – Concatenating strings


A concatenation or fusion of two separate strings

Concatening two different strings in VBA is straightforward.

Using the ‘&’ simple between two different strings merges them together.

So for example if you would like to merge a cell reference with a variable, it would look like this.

It would look like this.

Sub MergeCells()

Dim lRow As Long

lRow = Sheets(1).Cells(Rows.Count).End(xlUp).Row

Sheets(1).Range("B" & lRow).Copy

Sheets(2).Range("C2").PasteSpecial

End Sub

Concatenating two strings is very useful when we will start doing loops.

Speaking of, next few lessons… loops

No homework today.

Verified by MonsterInsights