I'm in Access VBA trying to create and manipulate an Excel workbook. I fill two worksheets and need to use the Excel VLOOKUP formula in one worksheet to lookup values in the other worksheet. I need to fill a column of cells with the VLOOKUP function but when the code reaches the line:
xlWs.Range("O2:O" & xlWs.Cells.SpecialCells(xlLastCell).Row).FormulaR1 C1 = "=VLOOKUP(P2,OK!$G$2:$G$" & LastStateRow & ",1,FALSE)"
I get a 1004 error "Application-defined or object-defined error".
The following previous line:
xlWs.Range("O2:O" & xlWs.Cells.SpecialCells(xlLastCell).Row).FormulaR1 C1 = "=RC[1]&RC[-12]"
works just fine.
I read that VBA doesn't like #N/A and that might be what's going on here. My question is how can I insert the VLOOKUP formula in the column cells even if VBA encounters #N/A, if that's the problem.
Thanks.