ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SpinButton Enable/Disable (https://www.excelbanter.com/excel-programming/319362-spinbutton-enable-disable.html)

MikeL

SpinButton Enable/Disable
 
Hi,

Does anyone know if a spinbutton can be disabled by its up or down button
only (e.g. disable its up button when it reaches its max value, but keeping
its down button enable)? If so how?

Please note I am using Excel 97.

Thanks in advance.

MikeL

Bob Phillips[_6_]

SpinButton Enable/Disable
 
Mike,

Wouldn't have thought so, it is a property of the control, not part of the
control.

You would normally just test if the value is already the max, and if so,
ignore the up in this case.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"MikeL" wrote in message
...
Hi,

Does anyone know if a spinbutton can be disabled by its up or down button
only (e.g. disable its up button when it reaches its max value, but

keeping
its down button enable)? If so how?

Please note I am using Excel 97.

Thanks in advance.

MikeL





Sharad

SpinButton Enable/Disable
 

Whether excel97 or higher it is not possible to disable only one of the
buttons of SpinButton.
What you can do is:-

Add a blank image on the up arrow button covering it (Image1).
Then following code:-

Private Sub SpinButton1_Change()
If SpinButton1.Value = SpinButton1.Max Then
Image1.Visible = True
Else
Image1.Visible = False
End If
End Sub


Private Sub SpinButton1_SpinUp()
'if spinbutton is in a worksheet
SpinButton1.BottomRightCell.Select

'or if it is on a userform
'something_else.SetFocus
End Sub

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

MikeL

SpinButton Enable/Disable
 
Thanks Sharad.

Will try your code later.

MikeL


"Sharad" wrote:


Whether excel97 or higher it is not possible to disable only one of the
buttons of SpinButton.
What you can do is:-

Add a blank image on the up arrow button covering it (Image1).
Then following code:-

Private Sub SpinButton1_Change()
If SpinButton1.Value = SpinButton1.Max Then
Image1.Visible = True
Else
Image1.Visible = False
End If
End Sub


Private Sub SpinButton1_SpinUp()
'if spinbutton is in a worksheet
SpinButton1.BottomRightCell.Select

'or if it is on a userform
'something_else.SetFocus
End Sub

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



All times are GMT +1. The time now is 06:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com