こんばんは!
色々方法はあるかと思いますが・・・
一例です。
配置は画像通りとします。
Private Sub CommandButton1_Click()
Dim i, j As Long
j = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(6, 2), Cells(j, 2)).ClearContents
If WorksheetFunction.CountIf(Range(Cells(6, 1), Cells(j, 1)), Cells(2, 1)) Then
i = WorksheetFunction.Match(Cells(2, 1), Range(Cells(6, 1), Cells(j, 1)), False)
Cells(i + 5, 2) = Cells(2, 2)
End If
End Sub
※ LOOPさせる場合は
Private Sub CommandButton1_Click()
Dim i As Long
i = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(6, 2), Cells(i, 2)).ClearContents
For i = 6 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(i, 1) = Cells(2, 1) Then
Cells(i, 2) = Cells(2, 2)
End If
Next i
End Sub
こんな感じではどうでしょうか?m(_ _)m
お礼
ご回答ありがとうございました。 私のレベルでは理解するのに時間はかかりそうだと思いますが、少しずつ進めていこうと思います。 macro4は絶妙でした。 まさに、私がしたい事がぴったり出来る方法で勉強になりました。