Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Agreeing with what @AlanWaage is saying, you should put the actual <code>VLOOKUP</code> formula in the cell. Then, to get the formula to update relative to its location, you can utilize copy and paste. Finally, once you have the formulas there, you can copy and paste values, and do your replacement based on the values now in <code>CellsForFormula</code> range. See the updated code below:</p> <pre><code>' Put the formula in the first cell of your range CellsForFormula(1, 1).Formula = _ "=VLOOKUP(Paste Daily Data!B2,Logic Statements!$A$1:$D$10000,4,0)" ' Copy the formula to the rest of your range CellsForFormula(1, 1).Copy _ Destination:=Range(CellsForFormula(2, 1), CellsForFormula(NumRecords - 1, 1)) ' Copy and paste values to just get the values in your range CellsForFormula.Copy CellsForFormula.PasteSpecial Paste:=xlPasteValues ' Execute your replacement for each cell in CellsForFormula cell.Replace("ZZZ", cell.offset(0,-4).Address) 'Use the line below instead of the line above if you only 'want to replace if the entire value is "ZZZ" 'cell.Replace("ZZZ", cell.offset(0,-4).Address,xlWhole) cell.Formula = "=" &amp; cell.value Next cell </code></pre> <p><strong>---EDIT---</strong></p> <p>Note that I did <code>Logic Statements!$A$1:$D$10000</code> instead of <code>Logic Statements!A:D</code>; this will be much faster than having Excel examine all rows in the columns A:D. Make this number larger or smaller as you see fit, but you should try to avoid using complete column/row references in formulas unless necessary</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload