Skip to content

Instantly share code, notes, and snippets.

@ricdeez
Created January 17, 2013 07:08
Show Gist options
  • Save ricdeez/4554270 to your computer and use it in GitHub Desktop.
Save ricdeez/4554270 to your computer and use it in GitHub Desktop.
VBA: Join Cells on a Spreadsheet
Public Sub JoinCells()
Dim xls As Excel.Worksheet
Dim cell As Excel.Range
Dim destn_rge As Excel.Range
Dim combined As String
Dim i As Long
i = 0
Set destn_rge = Nothing
combined = ""
For Each cell In Selection
i = i + 1
If i = 1 Then
Set destn_rge = cell
End If
combined = combined & cell.Value & vbCrLf
Next cell
destn_rge.Value = combined
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment