Supongamos que tenemos muchas celdas que necesitamos fusionar con texto. En el conjunto estándar Excel hay una función similar: "Fusionar y centro" , pero al realizar la unión deja solo el texto de la celda más externa. Por tanto, necesitamos utilizar nuestra propia macro para tales fines.
Para hacer esto, abra el editor Visual Basic (Alt+F11), inserte el módulo VBA (
Sub MergeToOneCell()
'moonexcel.com.ua
Const sDELIM As String = " "
Dim rCell As Range
Dim sMergeStr As String
If TypeName(Selection) <> "Range" Then Exit Sub
With Selection
For Each rCell In .Cells
sMergeStr = sMergeStr & sDELIM & rCell.Text
Next rCell
Application.DisplayAlerts = False
.Merge Across:=False
Application.DisplayAlerts = True
.Item(1).Value = Mid(sMergeStr, 1 + Len(sDELIM))
End With
End Sub
Guarde y regrese a Excel.
Ahora seleccione las celdas requeridas y ejecute nuestra macro (Alt+F8) (nombre de la macro: "MergeCell").