ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Enable Command Button 1 & 2 (https://www.excelbanter.com/excel-programming/332069-enable-command-button-1-2-a.html)

Mikeice[_20_]

Enable Command Button 1 & 2
 

HI ALL.

COuld anyone help me with the VBA code I require to enable two command
buttons if cell b6 is between 0 and 9999.

So I have disable the buttons and what I want is when a number between
the above is entered this enables both the command buttons but when
either command button is pressed they go back to disabled.

Is that possible or pie in the sky.

thx in advance


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=379981


mangesh_yadav[_331_]

Enable Command Button 1 & 2
 

Private Sub CommandButton1_Click()
CommandButton1.Enabled = False
' your code here
End Sub

Private Sub CommandButton2_Click()
CommandButton2.Enabled = False
' your code here
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$6" And Target.Value = 0 And Target.Value
<= 9999 Then
CommandButton1.Enabled = True
CommandButton2.Enabled = True
End If
End Sub


should go in the module of the concerned sheet

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=379981


Mikeice[_21_]

Enable Command Button 1 & 2
 

Thx Mangesh your a champion

--
Mikeic
-----------------------------------------------------------------------
Mikeice's Profile: http://www.excelforum.com/member.php...fo&userid=2246
View this thread: http://www.excelforum.com/showthread.php?threadid=37998


mangesh_yadav[_332_]

Enable Command Button 1 & 2
 

:)
Thanks for the feedback.

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=379981



All times are GMT +1. The time now is 08:20 AM.

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