Created
January 17, 2013 07:08
-
-
Save ricdeez/4554270 to your computer and use it in GitHub Desktop.
VBA: Join Cells on a Spreadsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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