monirg
Well-known Member
- Joined
- Jan 11, 2005
- Messages
- 629
Hello;
I've a reference-contained formula repeated exactly in numerous VBA macros in the same code:
To change or modify the above formula, the code is searched and the same changes are made to the same formula everywhere!!
That's clearly not an efficient way, besides it does not preclude the possibility of missing some!
Can I place the formula statement, and only the formula statement:
in a separate macro, and make reference to the macro in the corresponding procedures: Sub Test_1(), Sub Test_2(), ..., etc. ???
How ???
This way, changes/modifications to the formula could be made in one location only.
Thank you kindly for your help.
I've a reference-contained formula repeated exactly in numerous VBA macros in the same code:
Code:
Sub Test_1()
' ...... code 1
Set myFormula = myRange.Offset(, myRange.Rows.Count).Rows(1)
myFormula.Formula = "=C21*$D$18^D21*$E$18^E21*$F$18^0.35*$G$18^G21/$H$18^H21*$I$18^I21"
' ...... code 11
End Sub
Sub Test_2()
' ...... code 2
Set myFormula = myRange.Offset(, myRange.Columns.Count).Columns(1)
myFormula.Formula = "=C21*$D$18^D21*$E$18^E21*$F$18^0.35*$G$18^G21/$H$18^H21*$I$18^I21"
' ...... code 22
End Sub
'etc
That's clearly not an efficient way, besides it does not preclude the possibility of missing some!
Can I place the formula statement, and only the formula statement:
Code:
myFormula.Formula: = "=C21*$D$18^D21*$E$18^E21*$F$18^0.35*$G$18^G21/$H$18^H21*$I$18^I21"
How ???
This way, changes/modifications to the formula could be made in one location only.
Thank you kindly for your help.