Hello, I have quite a challenge here .. I am trying to lookup multiple values from 2 different tables from different sheets in a single workbook (different from the one I am applying VBA to)
I wrote this code from scratch but the from so I apologize in advance for the obvious errors or redundancies.
I am getting a
I would love any help I could get in resolving this!
TIA!!
I wrote this code from scratch but the from so I apologize in advance for the obvious errors or redundancies.
I am getting a
on the code.Run-time error '13': Type mismatch
I would love any help I could get in resolving this!
TIA!!
VBA Code:
Sub CheckPayments()
Dim wkb As Excel.Workbook
Dim Payment As Excel.Worksheet
Dim SalesList As Excel.Worksheet
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim NewTable As Object
Dim a As Variant
Dim ProcessID As Long
Dim SalesID As Long
Dim id As String
Dim PayOK As Boolean
Dim EPay As Boolean
Dim Delay As Boolean
Dim Cancelled As Boolean
Dim TKC As Boolean
Dim Tokurei As Boolean
Dim NoPay As Boolean
Dim EpayR As Long
Dim DelayR As Long
Dim CancelR As Long
Dim TKCR As Long
Dim TokureiR As Long
Dim NoPayR As Long
Set wkb = Excel.Workbooks("Payment Check Tool.xlsx")
Set Payment = wkb.Worksheets("Processing")
EpayR = wkb.Worksheets("Processing").ListObjects("Process").ListColumns("Payment")
DelayR = wkb.Worksheets("Processing").ListColumns("Delay")
ProcessID = wkb.Worksheets("Processing").ListColumns("Client ID")
Set SalesList = wkb.Worksheets("Sales List Import").ListObjects("SalesList")
CancelR = wkb.Worksheets("Sales List Import").ListObjects("SalesList").ListColumns("Cancellation")
TKCR = wkb.Worksheets("Sales List Import").ListObjects("SalesList").ListColumns("Tokurei Release Date")
TokureiR = wkb.Worksheets("Sales List Import").ListObjects("SalesList").ListColumns("Tokurei")
NoPayR = wkb.Worksheets("Sales List Import").ListObjects("SalesList").ListColumns("Deposit Date(1st)")
SalesID = wkb.Worksheets("Sales List Import").ListObjects("SalesList").ListColumns("Purchaser ID")
Set wb = Application.ThisWorkbook
Set ws = wb.Sheets("Sheet1")
Set NewTable = ws.ListObjects("Table1")
Set a = NewTable.DataBodyRange.Value
For i = 1 To UBound(a)
If a(i, ProcessID) = id Then
If a(i, EpayR).Value = "E-PAY" Then
If a(i, DelayR).Value = "DELAY" Or a(i, DelayR).Value = True Then
Delay = True
Else
PayOK = True
NewTable.Range("B" & i).Value = "OK"
End If
ElseIf a(i, SalesID) = id Then
If a(i, CancelR).Value <> "" Then
Cancelled = True
NewTable.Range("B" & i).Value = "Cancelled"
ElseIf a(i, TKCR).Value <> "" Then
TKC = True
NewTable.Range("B" & i).Value = "TKC Done"
ElseIf a(i, TokureiR).Value <> "" Then
Tokurei = True
NewTable.Range("B" & i).Value = "Tokurei"
ElseIf a(i, NoPayR).Value = "" Then
NoPay = True
NewTable.Range("B" & i).Value = "NO PAYMENT"
End If
EPay = False
Delay = False
PayOK = False
Cancelled = False
TKC = False
Tokurei = False
NoPay = False
End If
End If
Exit For
Next i
End Sub