VBA的には該当シートのシートモジュールに以下のような感じでよろしいかと思います。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Range
For Each C In Target
If Not Intersect(C, Range("A:A,C:C,E:E")) Is Nothing Then
Application.EnableEvents = False
If Cells(C.Row, "A").Value = "" And Cells(C.Row, "C").Value = "" And Cells(C.Row, "E").Value = "" Then
Cells(C.Row, "G").ClearContents
Else
Cells(C.Row, "G").Value = Cells(C.Row, "A") & "-" & Cells(C.Row, "C") & "-" & Cells(C.Row, "E")
End If
Application.EnableEvents = True
ElseIf Not Intersect(C, Range("B:B,D:D,F:F")) Is Nothing Then
Application.EnableEvents = False
If Cells(C.Row, "B").Value = "" And Cells(C.Row, "D").Value = "" And Cells(C.Row, "F").Value = "" Then
Cells(C.Row, "H").ClearContents
Else
Cells(C.Row, "H").Value = Cells(C.Row, "B") & "-" & Cells(C.Row, "D") & "-" & Cells(C.Row, "F")
End If
Application.EnableEvents = True
End If
Next C
End Sub
お礼
回答ありがとうございました。 とても合理的で、素晴らしい記述だと思います。 大変勉強になりました。使わせていただきます。