| 
    
     |  | 縦でも横でも、すべてに値が入力されている3つのセルを選択し、 右クリックすることによって選択した先頭のセルに文字をまとめる。
 というイベントマクロです。シートモジュールに入れて下さい。
 
 Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
 Cancel As Boolean)
 Dim Tg As Range
 Dim MyV As Variant
 Dim Mst As String
 
 Set Tg = Target
 If Tg.Areas.Count > 1 Or Tg.Count <> 3 Then GoTo ELine
 With WorksheetFunction
 If .CountA(Tg) < 3 Then GoTo ELine
 Cancel = True
 MyV = .Transpose(.Transpose(Tg.Value))
 If Tg.Columns.Count = 1 Then
 MyV = .Transpose(MyV)
 End If
 End With
 Mst = Replace(Join(MyV), Chr(32), "")
 Tg.Cells(1).Value = Mst
 ELine:
 Set Tg = Nothing
 End Sub
 
 |  |