ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for inactivating button (https://www.excelbanter.com/excel-programming/381795-vba-code-inactivating-button.html)

Raj[_10_]

VBA code for inactivating button
 
Hi I want to know if somebdy can help me VBA code for inactivating a
button if the value of a particular cell say C1 is blank.

Example: On Sheet1 have a button "knowledge" and on clicking this
button a sheet2 opens which have two buttons K1 and K2. I want if value
of a particular cell say C1 (on Sheet1) is blank then K1 should become
inactive or is disabled, otherwise it should be active. Similarly if
cell C2 (on Sheet1) is a blank the button (K2 on Sheet2)) should be
should be inactive else it should be active.

Hope i have made my question clear.

Regards
Raj


Corey

VBA code for inactivating button
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("C1").Value = "" Then
K1.Enabled = False
Else
K1.Enabled = True
End If

If Range("C2").Value = "" Then
K2.Enabled = False
Else
K2.Enabled = True
End If

End Sub



Corey....

"Raj" wrote in message
oups.com...
Hi I want to know if somebdy can help me VBA code for inactivating a
button if the value of a particular cell say C1 is blank.

Example: On Sheet1 have a button "knowledge" and on clicking this
button a sheet2 opens which have two buttons K1 and K2. I want if value
of a particular cell say C1 (on Sheet1) is blank then K1 should become
inactive or is disabled, otherwise it should be active. Similarly if
cell C2 (on Sheet1) is a blank the button (K2 on Sheet2)) should be
should be inactive else it should be active.

Hope i have made my question clear.

Regards
Raj





All times are GMT +1. The time now is 01:52 PM.

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