シートから名前を取得し(「名前」というシートでA2としましょう)、別のワークシートで同じ名前を検索します(「ジョブ」でA2と言います)。その名前が他のワークシートで見つかった後、そのすぐ隣のセルから値をコピーして(まだ「ジョブ」にありますが、B2)、最初のシートの別のセル(E2)に戻します(「名前」) 。最終的には、「名前」のA1のすべての値をループして、シート全体に入力したいと思います。
私はこれまでに得ました:
Sub fixThis()
Dim i As Long, j As Long, col1 As Long, col2 As Long, lastrow1 As Long, lastrow2 As Long
Dim sheetOne As String
Dim sheetTwo As String
col1 = 5
col2 = 1
sheetOne = "Names"
sheetTwo = "Job"
lastrow1 = Cells(Rows.Count, col1).End(xlUp).Row
lastrow2 = Cells(Rows.Count, col2).End(xlUp).Row
For i = 2 To lastrow1
For j = 2 To lastrow2
If sheetOne.Cells(i, col1).Value = sheetTwo.Cells(j, col2).Value Then
sheetOne.Cells(i, 6).Value = sheetTwo.Cells(j, 2).Value
End If
Next
Next
End Sub