ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable command button (https://www.excelbanter.com/excel-programming/332076-disable-command-button.html)

Mikeice[_22_]

Disable command button
 

I have a command button that I have disabled unless a certain number is
entered.
but I need it disabled also if the cell is blank any ideas.

Here is the code thus far.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Sheets("Quality Accessing Template").Range("B6").Value = 0 And
Sheets("Quality Accessing Template").Range("B6").Value <= 9999 Then
Sheets("Quality Accessing Template").CommandButton1.Enabled = True

Else

Sheets("Quality Accessing Template").CommandButton1.Enabled = False

End If


End Sub


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


Bob Phillips[_7_]

Disable command button
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Sheets("Quality Accessing Template")
If Not IsEmpty(.Range("B6").Value) Then
If .Range("B6").Value = 0 And _
.Range("B6").Value <= 9999 Then
.CommandButton1.Enabled = True
Else
.CommandButton1.Enabled = False
End If
Else
.CommandButton1.Enabled = False
End If
End With
End Sub

--
HTH

Bob Phillips

"Mikeice" wrote in
message ...

I have a command button that I have disabled unless a certain number is
entered.
but I need it disabled also if the cell is blank any ideas.

Here is the code thus far.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Sheets("Quality Accessing Template").Range("B6").Value = 0 And
Sheets("Quality Accessing Template").Range("B6").Value <= 9999 Then
Sheets("Quality Accessing Template").CommandButton1.Enabled = True

Else

Sheets("Quality Accessing Template").CommandButton1.Enabled = False

End If


End Sub


--
Mikeice
------------------------------------------------------------------------
Mikeice's Profile:

http://www.excelforum.com/member.php...o&userid=22467
View this thread: http://www.excelforum.com/showthread...hreadid=380000




mangesh_yadav[_338_]

Disable command button
 

Private Sub Worksheet_Change(ByVal Target As Range)
If Sheets("Quality Accessing Template").Range("B6").Value = 0 And
Sheets("Quality Accessing Template").Range("B6").Value <= 9999 And
Sheets("Quality Accessing Template").Range("B6") < "" Then

Sheets("Quality Accessing Template").CommandButton1.Enabled = True

Else

Sheets("Quality Accessing Template").CommandButton1.Enabled = False

End If

End Sub



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=380000



All times are GMT +1. The time now is 11:46 PM.

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