0

I applied a Vlookup formula to a row in a column and I want to apply same formula to multiple rows of same column.

My Code is:

Range("G5")
ActiveCell.FormulaR1C1 = "=VLOOKUP(c[-6],sheet!c[-6],1,0)"
Range("G5")
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • 2
    You can apply a formula to an entire range at once. `Range("myrange").FormulaR1C1 = ...` – BigBen May 15 '19 at 13:19
  • 1
    You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). • This fills the formula into range G5:G10: `Range("G5:G10").FormulaR1C1 = "=VLOOKUP(c[-6],sheet!c[-6],1,0)"` – Pᴇʜ May 15 '19 at 13:27
  • To add onto @BigBen , if you put a formula in a range with relative references, they will update based on the **first cell** in the range, e.g., `.formula = "=A1"` will show up as A1, A2, A3, A4, etc., as it fills down the column, but `.formula = "=A$1"` will put A$1 into all cells down the column, as opposed to column-to-column where it will go A$1, B$1, C$1, etc. This will occur regardless of your first cell in the range being A1, GD325, etc., so it helps to keep track of your starting location. – Cyril May 15 '19 at 13:55

0 Answers0