In order to get dynamic formulas to develop through VBA, I had to use INDIRECT(ADDRESS(. I am now stuck with several dozen formulas that look like this:
=INDIRECT(ADDRESS(37,10),1)*(INDIRECT(ADDRESS(37,7),1)+(INDIRECT(ADDRESS(69,10),1)*INDIRECT(ADDRESS(77,10),1))+(INDIRECT(ADDRESS(70,10),1)*INDIRECT(ADDRESS(78,10),1))+(INDIRECT(ADDRESS(71,10),1)*INDIRECT(ADDRESS(79,10),1))+(INDIRECT(ADDRESS(72,10),1)*INDIRECT(ADDRESS(80,10),1))+(INDIRECT(ADDRESS(73,10),1)*INDIRECT(ADDRESS(81,10),1))+(INDIRECT(ADDRESS(74,10),1)*INDIRECT(ADDRESS(82,10),1))+(INDIRECT(ADDRESS(75,10),1)*INDIRECT(ADDRESS(83,10),1)))
I cannot use these formulas with Solver because it is too much for Solver. When I manually translate the formulas to "A1" format, then Solver works. I need to automate the translation because this is meant to be a template.
I was hoping that replacing "INDIRECT(ADDRESS" with "Cells" might work. No luck. Is there an expression I can use that can replace "INDIRECT(ADDRESS" that will read the R1C1 format? Or do you have a better solution?
Thanks!
r = 0
Do Until r = 6
i = 0
Do Until i = DCShipFrom
Cells(70 + r, 7 + DCShipFrom + i).Select
Selection.FormulaR1C1 = "=IF(AND(INDIRECT(ADDRESS(" & 67 & "," & 7 + DCShipFrom + i & "),1)<=" & "INDIRECT(ADDRESS(" & 70 + r & "," & 6 & "),1)," & "INDIRECT(ADDRESS(" & 67 & "," & 7 + DCShipFrom + i & "),1)>" & "INDIRECT(ADDRESS(" & 69 + r & "," & 6 & "),1)),1,0)"
i = i + 1
Loop
r = r + 1
Loop
enter code here