

Super Formula Bar (easily edit multiple lines of text and formula) Reading Layout (easily read and edit large numbers of cells) Paste to Filtered Range.Reuse: Quickly insert complex formulas, charts and anything that you have used before Encrypt Cells with password Create Mailing List and send emails.

The Best Office Productivity Tools Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by Then save and close the code window, now, if the cell value in A1 is greater than B1, the button is enabled, else, if the cell value in A1 is less than B1, the button is disabled, see screenshot: Note: In the above code, A1 and B1 are the cell values that you use, CommanButton1 is the button name, change them to your own.Ģ. If (TargetAdd = Range("A1").Address) Or (TargetAdd = Range("B1").Address) Then VBA code: Enable or disable a button based on two cell values: Private Sub Worksheet_Change(ByVal Target As Range) Right click the sheet that contain the button, and then choose View Code from the context menu, in the Microsoft Visual Basic for Applications window, please copy and paste the below code into the blank module, see screenshot: The following VBA code also can do you a favor.ġ.

If you want to enable or disable a command button based on two cell values, such as, when value in A1 is greater than value in B1, the button is enable, else, the button is disable. (4.) Two buttons are all disabled if there is no data in Column A and Column C, see screenshot:Įnable or disable a button based on two cell values with VBA code (3.) Both Column A and Column C have data, two buttons are all enabled, see screenshot: (2.) If type data in Column C, the button 2 is enabled and button 1 is disabled, see screenshot: (1.) If type data in Column A, the button 1 is enabled and button 2 is disabled, see screenshot: Then save and close the code window, now, you will get the following result as you need:

Note: In the above code, CommandButton1 and CommandButton2are the buttons names, A:A and C:Care the two columns that you use to enable or disable two buttons, please change them to your need.ģ. VBA code: Enable or disable two buttons based on two columns: Private Sub Worksheet_Change(ByVal Target As Range) In the Microsoft Visual Basic for Applications window, please copy and paste the below code into the blank module: Right click the sheet that contain the buttons, and then choose View Code from the context menu, see screenshot:Ģ. To solve this task, the following VBA code may help you.ġ. Amazing! Using Efficient Tabs in Excel Like Chrome, Firefox and Safari! Save 50% of your time, and reduce thousands of mouse clicks for you every day!įor example, I have two command buttons in a worksheet, if Column A has data, the button1 is enable, and button 2 is disable if Column C contains data, the button 2 is enable, and button 1 is disable.
