I am trying to use a few Named Ranges together in a formula in VBA, however it seems to take very long for excel to calculate. The Named Ranges have almost 70k of data each (All have the same number of rows). Below is an example of the code:
Dim i, erow, ecol As Long
erow = Sheets("Sheet1").Range("A11").End(xlDown).Row
ecol = Sheets("Sheet1").Range("A11").End(xlToRight).Column
Sheets("Sheet1").Range(Cells(12, ecol + 2), Cells(erow, ecol + 2)).Formula = "=(0.03 - Ith_LT) * (a_LI_LT * 0.03 ^ 2 + b_LI_LT * 0.03 + c_LI_LT)
Ith_LT, a_LI_LT, b_LI_LT, c_LI_LT are the named ranges.
I am trying to speed this up by first storing the named ranges in memory then calling it but to no avail. Below is my code.
Dim i, erow, ecol As Long
Dim Ith, a, b, c As Variant
erow = Sheets("Sheet1").Range("A11").End(xlDown).Row
ecol = Sheets("Sheet1").Range("A11").End(xlToRight).Column
Ith = Range("Ith_LT")
a = Range("a_LI_LT")
b = Range("b_LI_LT")
c = Range("c_LI_LT")
Sheets("Sheet1").Range(Cells(12, ecol + 2), Cells(erow, ecol + 2)).Value = (0.03 - Ith) * (a * 0.03 ^ 2 + b * 0.03 + c)
When i run this, a type mismatch error pops up. Is there any way to make this work? or are there anyway to make this code run faster? Thank you.