|
tbtk さん
こんにちは。
テストしてないですけど、
背番号のほうを配列に格納しての、
For~Next二重回しです。
Sub データ一致()
Dim myVal As Variant
Dim myWb As Workbook, dataWb As Workbook
Dim i As Integer, j As Integer
Set myWb = Workbooks("データ取り込み.xls")
Set dataWb = Workbooks("背番号.xls")
myVal = dataWb.ActiveSheet.Columns("A:B")
For i = 1 To CInt(myWb.ActiveSheet.Range("B65536").End(xlUp).Row)
For j = LBound(myVal) To UBound(myVal)
If myWb.ActiveSheet.Range("B" & i).Value = myVal(j, 1) Then
myWb.ActiveSheet.Range("D" & i).Value = myVal(j, 2)
Exit For
End If
Next j
Next i
End Sub
|
|