Currently using vba with excel 2007 ...
I am currently testing features and am a bit stuck with the buttons. I have two buttons called ONE and TWO. Pressing a button calls the Calc function with each button passing a variable to a different name. As below:
Private Sub ONE_Click() Calc TWO End Sub Private Sub TWO_Click() Calc ONE End Sub Function Calc(B As CommandButton) B.Enabled = False End Function
I understand that pressing the ONE button passes the TWO variable to the Calc function, and then disables the TWO button.
I also have a button labeled Reset, which works as follows:
Private Sub Reset_Click() ONE.Enabled = True TWO.Enabled = True End Sub
As a result of this, if I press the ONE button, the TWO button will turn gray and “disabled” will appear. However, when I press the Reset button, it remains gray. Studying the properties of the button shows that it does not actually turn off. I installed another button that directly disables button two, i.e. TWO.Enabled = False, instead of using a variable for this.
When a button is directly disabled using the direct button, a reset allows the button to do as it should, and the properties reflect that the button is disabled.
Does anyone know why using a variable to disable such a button disables illusions? And even better, how to solve the problem?
source share