Hi Guys

I have to do the following steps. I have written the code but its not working properly:

1. Select the first entry in Sheet (Inventory), column B (Barcode)
2. Search for a match on Sheet(Barcoded Files) Column A (Wincanton Code)
3. If there is a match, update the correct row in Sheet(Inventory) Column C (Issue) with the row number of the match from step 2 above & then proceed to step 5 below
4. If there is no match proceed to step 5
5. Select the next entry in Sheet (Inventory), column B (Barcode) and go to step 2


please see the code below. It takes ages to run:

Private Sub CommandButton1_Click()
  
Dim wb As Workbook
Dim Dest As Workbook
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim J As Integer
     Dim i As Integer
     Dim a As Date
     Dim t As Date
     Dim lastrow As Long
     i = 2
Set wb = ActiveWorkbook

Set ws1 = ThisWorkbook.Worksheets("Barcoded files")
Set ws = ThisWorkbook.Worksheets("ABC")
'Dim FoundCell As Excel.Range

'Set FoundCell = ws.Range("A:A").Find(what:=TextBox1.Value, lookat:=xlWhole)

'If Not FoundCell Is Nothing Then
   ' J = FoundCell.Row
'Else
   ' MsgBox (TextBox1.Value & " not found in sheet1")
   ' Exit Sub
'End If

lastrow = ws.UsedRange.Rows.Count
lastrow1 = ws1.UsedRange.Rows.Count


For i = 2 To lastrow
For J = 2 To lastrow1

If ws.Cells(i, "B").Value = ws1.Cells(J, "A").Value Then

ws.Cells(i, "C").Value = J
MsgBox J

Exit For

End If

Next J
Next i

End Sub
ANy help would be much appreciated.

Thanks