I'm using code similar to this to enter some formula's:-
Code:
Sub test()
With Range("D2 28008") .Formula = "=B2*C2" .Value = .Value
End With
With Range("E2:E28008") .Formula = "=vlookup(B2,TestData,5,false)" .Value = .Value
End With
With Range("F2:F28008") .Formula = "=B2*A2+3.658" .Value = .Value
End With
End Sub
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:
Sub test()
Dim arrrange
Dim arrformula
arrrange = Array("D2 10", "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
End Sub |