マクロ 57回
セルの結合をする時に、 そこに文字列が入力されていると、意図した通りにならないことが多いのです。
例えば、入力されている文字もつなげて欲しい場合があります。
エクセルのアラートが出て左上の値のみが保持されると他のセルの値は破棄されてしまいます。
(サンプルファイルは、こちらから
マクロ57回サンプルデータ)
Private Sub CommandButton2_Click() Selection.Merge End Sub




Private Sub CommandButton2_Click()
Dim hanni As Range
Dim moji As String
For Each hanni In Selection
moji = moji & " " & hanni.Text
Next
Selection.MergeCells = True
Selection.Value = moji
End Sub


Private Sub CommandButton2_Click()
Dim hanni As Range
Dim moji As String
For Each hanni In Selection
moji = moji & hanni.Text
Next
Application.DisplayAlerts = False
Selection.MergeCells = True
Selection.Value = moji
Application.DisplayAlerts = True
End Sub

