Private Sub CommandButton1_Click() Dim myRange As Range, meRange As Range, myAddress As String, i As Integer Set meRange = Range(“J3:J22”) Set myRange = meRange.Find(What:=Sheets(“test”).Range(“L2”).Value, LookIn:=xlValues) If Not myRange Is Nothing Then myAddress = myRange.Address i = 3 Do Cells(i, “L”).Value = myRange.Offset(, -8).Value Set myRange = meRange.FindNext(After:=myRange) i= i + 1 Loop Until myRange.Address = myAddress Else MsgBox”該当者がいません” End If End Sub
Private Sub CommandButton1_Click() Dim myRange As Range, meRange As Range, myAddress As String, i As Integer Set meRange = Range(“J3:J22”) Set myRange = meRange.Find(What:=Sheets(“test”).Range(“L2”).Value, LookIn:=xlValues) If Not myRange Is Nothing Then myAddress = myRange.Address i = 3 Do Cells(i, “L”).Value = myRange.Offset(, -8).Value Set myRange = meRange.FindNext(After:=myRange) i= i + 1 Loop Until myRange.Address = myAddress Else MsgBox”該当者がいません” End If Dim myyRange As Range, meeRange As Range, myyAddress As String, j As Integer Set meeRange = Range(“J3:J22”) Set myyRange = meeRange.Find(What:=Sheets(“test”).Range(“M2”).Value, LookIn:=xlValues) If Not myyRange Is Nothing Then myyAddress = myyRange.Address j = 3 Do Cells(j, “M”).Value = myyRange.Offset(, -8).Value Set myyRange = meeRange.FindNext(After:=myyRange) j= j + 1 Loop Until myyRange.Address = myyAddress Else MsgBox”該当者がいません” End If End Sub