I am trying to compare values in arrays after storing fields values from Excel sheet. I am getting error in this line -
If Trim(wsA.Cells(6, 116 + x).Value) = Trim(myArray1(i, 1).Value) Then
(424: Object required)
There are around 80000 values in columns A and D in PO file which I am storing in arrays myArray1 and myArray2.
The complete code is below: Request your help, Thanks
Sub UpdateQtyFrmPO()
StartTime = Timer
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Allocfile = Application.GetOpenFilename(FileFilter:="Excel Workbook (*.xl*; *.csv), *xl*;*.csv", _
Title:="Select the allocation file ")
If Not (Allocfile <> False) Then
MsgBox "Allocation file not selected. Update Aborted!", vbCritical
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
End If
Workbooks.Open Allocfile
Set Alloc = ActiveWorkbook
Set wsA = Alloc.ActiveSheet
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
POfile = Application.GetOpenFilename(FileFilter:="Excel Workbook (*.xl*; *.csv), *xl*;*.csv", _
Title:="Select the PO tracker file ")
If Not (POfile <> False) Then
MsgBox "PO tracker file not selected. Update Aborted!", vbCritical
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
End If
Workbooks.Open POfile
Set PO = ActiveWorkbook
Set wsP = PO.ActiveSheet
'''''''''''''
Dim myArray1 As Variant
Dim myArray2 As Variant
Dim myArray3 As Variant
lastrowP = wsP.Range("A1000000").End(xlUp).Row
lastrowA = wsA.Range("A1000000").End(xlUp).Row
wsA.Range("DM7:DT" & lastrowA).ClearContents
''''''''''''''''''''''''''''''''''''''''
myArray1 = wsP.Range("A1:A" & lastrowP).Value
myArray2 = wsP.Range("D1:D" & lastrowP).Value
myArray3 = wsA.Range("A1:A" & lastrowA).Value
For i = 1 To UBound(myArray1) ''''Job No
For j = 1 To UBound(myArray2) ''''Article
For k = 1 To UBound(myArray3) ''''ItemNo
If myArray3(k, 1) = myArray2(j, 1) Then
For x = 1 To 8
wsA.Activate
If Trim(wsA.Cells(6, 116 + x).Value) = Trim(myArray1(i, 1).Value) Then
Cells(k, 116 + x).Select
wsA.Cells(k, 116 + x).Value = Range("O" & i).Value
End If
Exit For
Next x
End If
Next k
Next j
Next i