Forum Discussion
Getting an error of "error type mismatch" for index match code
JoeUser2004 , i tried your method; there is no error when the code is executed but the index match is only populating the incorrect data; ie those accounts number that are inactive should be populated as inactive in the Lookup for acct status.xlsx file.
I have attached 2 workbooks; Lookup for acct status.xlsx and Corp_Aging.xlsx
Lookup for acct status.xlsx will be workbook that is containing the macro.
Vba code as follows:
Sub idAcc()
Dim ws As Worksheet
Dim agingwb As Workbook
Dim lastRow As Long
Dim i As Long
Dim a As Variant
Dim b As Variant
Dim c As Variant
Set ws = Sheet1
Set agingwb = Workbooks.Open("C:\Users\hrhquek\Desktop\Corp_Aging.xlsx")
ThisWorkbook.Activate
ws.Range("AA1").EntireColumn.Insert
ws.Range("AA1").Value = "Asset_Status"
lastRow = ws.Cells(ws.Rows.Count, "Z").End(xlUp).Row
a = Cells(2, 1)
b = Application.Match(a, agingwb.Sheets("details_open_amt_by_acc").Range("E:E"))
c = Application.Index(agingwb.Sheets("details_open_amt_by_acc").Range("A:A"), b)
For i = 2 To lastRow
Range("AA" & i).Value = Application.WorksheetFunction.IfNa(c, "")
Next i
End Sub
(Resubmitting response to correct bad previous suggestions.)
I'm afraid that I cannot help you further.
We are both making mistakes which have lead to a tangled mess.
I suggest that you "start over", sort of.
Attach Excel files that demonstrate the __original__ problem -- even before your CLng hack, which was misguided, as I explained previously.
(Previously, I suggested that you abandon this thread and start a new thread. That was a misdirection because it might bifurcate responses to this thread and the new thread.)