I'm using code similar to this to enter some formula's:-
With Range("D228008") .Formula = "=B2*C2" .Value = .Value
With Range("E2:E28008") .Formula = "=vlookup(B2,TestData,5,false)" .Value = .Value
With Range("F2:F28008") .Formula = "=B2*A2+3.658" .Value = .Value
In reality I'm populating 25 columns (different formulas) using this method which means I'm repeating the same piece of code.
I was wondering if there was a simpler way?
Hi, you'll need to alter the ranges and formulas i have inputted below which i used to test run the code.Code:
arrrange = Array("D210", "E2:E10", "F2:F10")
arrformula = Array("=B2*C2", "=A2*C2", "=D2*C2") For i = LBound(arrrange) To UBound(arrrange) With Range(arrrange(i)) .Formula = arrformula(i) .Value = .Value End With Next i