次の VBA はトリックを行う必要がありますSheet1 (Main)
。.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Sheet As Worksheet
Dim Index As Integer
Dim Count As Integer
Dim Match As Range
If Target.Rows.Count > 1 Or Target.Columns.Count > 1 Then
' You've done something that has edited lots of cells. Cant handle this.
Exit Sub
End If
Set Sheet = ThisWorkbook.Worksheets("Main")
If Not Intersect(Sheet.Range("D:D"), Target) Is Nothing Then
' The edited cell falls in the range D:D
Count = ThisWorkbook.Worksheets.Count
For Index = 1 To Count
If Not ThisWorkbook.Worksheets(Index).Name = Sheet.Name Then
Set Match = ThisWorkbook.Worksheets(Index).Range("D:D").Find(What:=Target.Value, LookIn:=xlValues)
If Not Match Is Nothing Then
'copy the line across
ThisWorkbook.Worksheets(Index).Range("A" & Match.Row & ":E" & Match.Row).Copy Sheet.Range("A" & Target.Row)
Exit For
End If
End If
Next Index
End If
If Match Is Nothing Then
' optional, if the target string is not found clear the line.
Sheet.Range("A" & Target.Row & ":E" & Target.Row).ClearContents
End If
End Sub