Try using the following macro, which is not very elegant, since it does not perform error checking, etc., but works. Assign the macro to the button, click the cell, click the macro button, select the desired (source) range to combine with the mouse (it will be automatically filled in the input field in the dialog box), click "OK", highlight the destination cell (it will autofill the input window in the next dialog box) click "OK", all cells will be merged with one space into the destination cell, which may be in the original source range). It's up to you to remove the extra cells manually. Work with two rows and columns, but not with blocks.
Sub JoinCells() Set xJoinRange = Application.InputBox(prompt:="Highlight source cells to merge", Type:=8) xSource = 0 xSource = xJoinRange.Rows.Count xType = "rows" If xSource = 1 Then xSource = xJoinRange.Columns.Count xType = "columns" End If Set xDestination = Application.InputBox(prompt:="Highlight destination cell", Type:=8) If xType = "rows" Then temp = xJoinRange.Rows(1).Value For i = 2 To xSource temp = temp & " " & xJoinRange.Rows(i).Value Next i Else temp = xJoinRange.Columns(1).Value For i = 2 To xSource temp = temp & " " & xJoinRange.Columns(i).Value Next i End If xDestination.Value = temp End Sub
Paul mcmahon
source share