abberyfarm
Well-known Member
- Joined
- Aug 14, 2011
- Messages
- 733
Hello,
I have two macros Mode5() and Mode6(). Each macro has 3 variables a1, a2 and s.
However, I'm will have trouble in subsequent macros where I call on the variables to be used in calculations because I have them declared twice.
The values for these variables will always be the same in both mode5() and mode6() and only the signs will different. Mode5() always positive and mode6() always negative. Therefore I was hoping that I could just declare the values of the variables in mode5() and then in mode6() it would automatically assign the value to a variable and make it negative.
For example I would define a1, a2 and s in mode5() as being 1, 2 and 3 and then perhaps in mode6() it would automatically assign different variables b1, b2 and bs as being -2.22, -0.44 and -3.2.
I thought something like this would work?
Would that be possible?
Thank you for your help.
I have two macros Mode5() and Mode6(). Each macro has 3 variables a1, a2 and s.
Code:
Sub Mode5()
Const a1 As Single = 1
Const a2 As Single = 2
Const s As Single = 3
.........
End sub
Sub Mode6()
Const a1 As Single = -1
Const a2 As Single = -2
Const s As Single = -3
.........
However, I'm will have trouble in subsequent macros where I call on the variables to be used in calculations because I have them declared twice.
The values for these variables will always be the same in both mode5() and mode6() and only the signs will different. Mode5() always positive and mode6() always negative. Therefore I was hoping that I could just declare the values of the variables in mode5() and then in mode6() it would automatically assign the value to a variable and make it negative.
For example I would define a1, a2 and s in mode5() as being 1, 2 and 3 and then perhaps in mode6() it would automatically assign different variables b1, b2 and bs as being -2.22, -0.44 and -3.2.
I thought something like this would work?
Code:
Public Const a1 As Single = 1
Public Const a2 As Single = 2
Public Const s As Single = 3
Sub Mode5()
End sub
Sub Mode6()
' Automatically assign variables b1, b2 and s as being negative
Const b1 As Single = -1
Const b2 As Single = -2
Const s As Single = -3
.........
Would that be possible?
Thank you for your help.