Hello,
I modified a code by Chandoo where the user can select text in multiple cells in a column and the code will add it to the clipboard, join the text in a cell that the user pastes to, separated by a comma.
I can't get the text to right justify or wrap in the cell after I paste the text.
Can someone help? Using Excel 2016.
Thank you in advance.
I modified a code by Chandoo where the user can select text in multiple cells in a column and the code will add it to the clipboard, join the text in a cell that the user pastes to, separated by a comma.
I can't get the text to right justify or wrap in the cell after I paste the text.
Can someone help? Using Excel 2016.
Thank you in advance.
Code:
Sub JoinAndMerge()'joins all the content in selected cells
'and puts the resulting text in clipboard to paste elsewhere
'then merges all cells
'https://chandoo.org/wp/merge-cells-without-loosing-data/
Dim outputText As String
Dim obj As New DataObject
Const delim = ", "
On Error Resume Next
For Each cell In Selection
outputText = outputText & cell.Value & delim
Next cell
With Selection
'.Clear
outputText = Left(outputText, Len(outputText) - 2) 'removes last comma and space
obj.SetText outputText
obj.PutInClipboard 'copy to clipboard
.Merge
.HorizontalAlignment = xlRight '<===HERE
.VerticalAlignment = xlBottom
.WrapText = True '<===HERE
End With
End Sub