Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Sh As Worksheet, Rng As Range, sRng As Range
Dim eRw As Long
Set Sh = Sheets("data")
If Not Intersect(Target, [C4]) Is Nothing Then
Dim Col As Byte
Set Rng = Sh.Range(Sh.[e3], Sh.[iv3].End(xlToLeft))
eRw = Sh.[b65500].End(xlUp).Row + 9
Set sRng = Rng.Find([C4].Value, , xlFormulas, xlPart)
If Not sRng Is Nothing Then
Col = sRng.Column - 1
[b6].Resize(eRw, 7).ClearContents
[b6].Resize(eRw, 3).Value = Sh.[b4].Resize(eRw, 3).Value
[e6].Resize(eRw, 2).Value = Sh.Cells(4, Col).Resize(eRw, 2).Value
End If
ElseIf Not Intersect(Target, [h3]) Is Nothing Then
Dim MyAdd As String
Set Rng = Sh.Range(Sh.[A3], Sh.[A65500].End(xlUp))
eRw = Rng.Rows.Count + 9
[b6].Resize(eRw, 7).ClearContents
Set sRng = Rng.Find([h3].Value, , xlValues, xlWhole)
If Not sRng Is Nothing Then
MyAdd = sRng.Address
Do
With [b65500].End(xlUp).Offset(1)
.Resize(, 3).Value = sRng.Offset(, 1).Resize(, 3).Value
End With
Set sRng = Rng.FindNext(sRng)
Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
End If
End If
End Sub