VBA using vlookup with variables

Copper Contributor

I have a macro that I'm trying to use vlookup in.  The cell where the data goes changes with each new person added to the table.  The table has 140 rows and starts with row 13.  I have code in place, that works, to find the next empty row.

My problem is when using vlookup in this macro it always returns "FALSE" as the answer. This is a new learning curve for me; I'm sure it can be done, but I've run out of ideas and youtube videos to review.  I'm posting the code below and hope there's a solution.

Thanks for your time in advance.

 

 

Code:

The ContRow & ContCol are filled by data that stored in cells in row 11.  I'm using columns 3 to 6 in row 11 to store the needed cell references.

 

Dim ContRow, ContCol As Integer

ContRow = .Range("C300").End(xlUp).Row + 1 ' find 1st empty row
For ContCol = 3 To 6
.Cells(ContRow, ContCol).Value = .Range(.Cells(11, ContCol).Value).Value
Next ContCol

 

' the Cells portion of the line works fine it's the vlookup that is failing


.Cells(ContRow, ContCol + 1).Value = ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[-17]C[-2],wardDB,2,FALSE)"

 

0 Replies