Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have a command button in excel that i want to be hidden initially, until another cell in the worksheet is a 3. How do I go about doing this in VBA? Thank you! MN |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If the value in the cell changes to 3 based on the user typing, I'd use a
Worksheet_Change event. If you want to try, rightclick on the sheet tab that should have this behavior and select View Code. Paste this into the code window that opened (usually on the right hand side of the screen): Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim myCell As Range Set myCell = Me.Range("A1") If Intersect(myCell, Target) Is Nothing Then Exit Sub End If If myCell.Value = 3 Then Me.CommandButton1.Visible = True Else Me.CommandButton1.Visible = False 'rehide it if the value changes??? End If End Sub On the other hand, if the value changes as a result of a formula, you could use a different worksheet event: Option Explicit Private Sub Worksheet_Calculate() Dim myCell As Range Set myCell = Me.Range("A1") If myCell.Value = 3 Then Me.CommandButton1.Visible = True Else Me.CommandButton1.Visible = False 'rehide it if the value changes??? End If End Sub On 05/17/2010 14:37, MacNut2004 wrote: Hello, I have a command button in excel that i want to be hidden initially, until another cell in the worksheet is a 3. How do I go about doing this in VBA? Thank you! MN |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
command button to unhide row | Excel Discussion (Misc queries) | |||
Hide and Unhide Rows button | Excel Programming | |||
Activex command to Hide/Unhide | Excel Worksheet Functions | |||
Command Button to Hide/Unhide Rows | Excel Discussion (Misc queries) | |||
Hide and unhide command gridlines etc... | Excel Programming |