PDA

View Full Version : Problem between macro event and SpinButton



Magic_Doctor
05-10-2016, 12:25 AM
Hello,

I have a SpinButton associated with an event macro.
When I click on a cell that triggers the macro event, a SpinButton appears or not. If I press the SpinButton and I want to hide it by clicking on the cell, the SpinButton not necessarily disappear when clicking.
Everything is explained on the sheet.

Thank you for answer.16141

Paul_Hossler
05-10-2016, 10:19 AM
If I'm understanding, then adding the two marked lines <<<<<<<<<<<<<<<<<<< will re-hide the spin button after clicking




Private Sub SpinButton1_SpinDown()
Application.EnableEvents = False 'disable "Worksheet_Change"
[C6] = resultado + SpinButton1.Value / 100
[C5] = [Round(C1 * C3 * F1 / (C2 * F2 * (C6 + C3)),2)]
MonBoSpin '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Application.EnableEvents = True 'activate "Worksheet_Change"
End Sub
'
Private Sub SpinButton1_SpinUp()
Application.EnableEvents = False 'disable "Worksheet_Change"
[C6] = resultado + SpinButton1.Value / 100
[C5] = [Round(C1 * C3 * F1 / (C2 * F2 * (C6 + C3)),2)]
MonBoSpin '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Application.EnableEvents = True 'activate "Worksheet_Change"
End Sub

Magic_Doctor
05-10-2016, 12:35 PM
Hello Paul_Hossler,


Thank you for your reply.
I made the changes you have indicated. Unfortunately the problem persists. In addition to the conditional format of the cell "C6" only works one in two increments or decrements.
I think the problem is that when you operate the SpinButton it is necessarily on an object and no cell of the sheet is selected.
When operates the SpinButton and that we want to make it disappear, if you click on any cell in the sheet and then clicking on the cell "B", then yes the SpinButton disappears with one click.

Magic_Doctor
05-10-2016, 01:42 PM
I finally solved the problem by adding:


Private Sub SpinButton1_GotFocus()
[C5].Select 'a cell must always be selected for the event macro cell-bound "B" is operational from 1st click on this cell
End Sub