私は顧客名の配列を持っています。この配列は重複でいっぱいであり、注文行の他のデータが異なる可能性があるため、重複する必要があります。このデータには一意の識別子がなく、1 つの注文のデータを、その顧客が配列に含まれるすべての行と比較する必要があります。
顧客が一致するすべての行を for ループで検索するのに問題があります。
どんな助けでも大歓迎です!
Dim prodlog As String
Dim orddate As Variant
Dim cus As String
Dim owner As String
Dim orddate2 As Variant
Dim owner2 As String
Dim LogCusts As Variant
LogCusts = Application.Transpose(Range("F3", Range("F" & Rows.count).End(xlUp)))
Dim loglen As Integer
loglen = UBound(LogCusts) - LBound(LogCusts)
Dim cust2 As Variant
For Each cust2 In LogCusts
Dim custrow As Integer
custrow = Application.Match(cust2, LogCusts, False) + 1
prodlog = Range(Cells(custrow, 5), Cells(custrow, 5)).Value
orddate = Range(Cells(custrow, 2), Cells(custrow, 2)).Value
cus = Range(Cells(custrow, 6), Cells(custrow, 6)).Value
owner = Range(Cells(custrow, 7), Cells(custrow, 7)).Value
databook.Activate
logjam.Select
orddate2 = Range(Cells(custrow + 1, 5), Cells(custrow + 1, 5)).Value
owner2 = Range(Cells(custrow + 1, 7), Cells(custrow + 1, 7)).Value
If IsEmpty(orddate) Then
Exit For
End If
If IsEmpty(prodlog) Then
trackbook.Activate
masterlog.Select
Range(Cells(custrow, 2), Cells(custrow, 17)).Clear
Else: While cus = cust2
If orddate = orddate2 And owner = owner2 Then
Range(Cells(custrow, 8), Cells(custrow, 8)).Value = prodlog
End If
Wend
End If
Next cust2