JoshuaKC29
New Member
- Joined
- Apr 20, 2019
- Messages
- 10
I was wondering if there was anyway to carry variables across multiple sub routines. What I want to do is set a macro to a button, and I want to use an integer to make small changes to the main sub routine.
I know I can accomplish this by making the button change a cell in excel, then making reference to that cell and setting it to 0 when completing the sub routine. But I'd prefer to do this all within VBA is possible.
An example of what I'd like to accomplish is declaring BtnValue as an Integer. When I press a button, it sets the BtnValue to X then calls the main subroutine which produces a message.
If X = 1 then message 1 is sent.
If X = 2 then message 2 is sent.
Just an idea I had in a my sleep and I want to know if its possible.
I know I can accomplish this by making the button change a cell in excel, then making reference to that cell and setting it to 0 when completing the sub routine. But I'd prefer to do this all within VBA is possible.
An example of what I'd like to accomplish is declaring BtnValue as an Integer. When I press a button, it sets the BtnValue to X then calls the main subroutine which produces a message.
If X = 1 then message 1 is sent.
If X = 2 then message 2 is sent.
Just an idea I had in a my sleep and I want to know if its possible.