I have a dataset across two worksheets with approx. 59k rows in each.
I need to take a part number from sheet 1, defined as "wsBomb" and reference this against sheet 2, defined as "wsEam". Once you have this, there is an offset of 8 to get the supplier number and copy this back into "wsBomb".
I have this process working for the first piece of data. I am struggling to get this to work within a loop.
Edit
The findnext
function has been implemented and is looping through and changing the part number as required. However, this is only referencing cell L2 and not incrementing:
Sub Macro1()
Set wbTrying = Workbooks("RME EAM")
Set wsBomb = wbTrying.Worksheets("Bomb")
Set wsEam = wbTrying.Worksheets("EAM")
rowCounterPartNumber = 2
Set wf = Application.WorksheetFunction
Set rng1 = wsBomb.Range("E" & rowCounterPartNumber)
filterStr = wf.Transpose(rng1)
Dim partNumber As Range
Set partNumber = wsEam.Range("L:L").Find(What:=rng1.Value, LookIn:=xlValues, lookat:=xlWhole)
Dim partNo
For Each partNo In partNumber
If Not partNo Is Nothing Then
Do
wsBomb.Range("D" & rowCounterPartNumber).Value = partNumber.Offset(, -8)
rowCounterPartNumber = rowCounterPartNumber + 1
Set partNumber = wsEam.Range("L2:L60000").FindNext(partNumber)
If partNo Is Nothing Then
GoTo finished
End If
Loop While partNo <> ""
End If
finished:
Next
End Sub
Current output:
All part numbers are the same
The issue appears to be in the Set partNumber = wsEam.Range("L:L").Find(What:=rng1.Value, LookIn:=xlValues, lookat:=xlWhole)
section, as the rowCounterPartNumber
does not increment for column E or L.
I think is due to these being defined outside the loop.