Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a command button invisible or visible?
I have two command buttons. One hides a range of columns with VB code. One
unhides the same range with VB code. Due to space constraints I would like to have the 'hide" button set the visible property of that button to false and the "hide button" to true and visa-versa with the other button. By placing the buttons on top of each other the proper button is always visible and space used is compact. I am new to VB and can't get this to work although I assume it is possible. Suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a command button invisible or visible?
hi,
no need to do that. you can combine the show/hide in one button. here is some code i use. it only hide 1 column at a time but you can modify it to your needs. it also changes the button color and captions so that i can use the button as a header.(same more space) Private Sub CommandButton1_Click() ' hide/show column If Columns("L:L").Hidden = True Then Columns("K:K").Hidden = True Columns("L:L").Hidden = False CommandButton1.Caption = "inches" CommandButton1.BackColor = &HFF& Else Columns("K:K").Hidden = False Columns("L:L").Hidden = True CommandButton1.Caption = "cms" CommandButton1.BackColor = &HC000& End If End Sub -----Original Message----- I have two command buttons. One hides a range of columns with VB code. One unhides the same range with VB code. Due to space constraints I would like to have the 'hide" button set the visible property of that button to false and the "hide button" to true and visa-versa with the other button. By placing the buttons on top of each other the proper button is always visible and space used is compact. I am new to VB and can't get this to work although I assume it is possible. Suggestions? . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a command button invisible or visible?
Here is some code to just change the caption on the button. Generally a
better way to go. This assumes that the button that you got came off of the control toolbox, and you go into properties of that button and change the Name to cmdHide. Private Sub cmdHide_Click() If ActiveSheet.Range("A11:A14").EntireRow.Hidden = False Then ActiveSheet.Range("A11:A14").EntireRow.Hidden = True ActiveSheet.cmdHide.Caption = "Unhide" Else ActiveSheet.Range("A11:A14").EntireRow.Hidden = False ActiveSheet.cmdHide.Caption = "Hide" End If End Sub HTH "Mandora" wrote: I have two command buttons. One hides a range of columns with VB code. One unhides the same range with VB code. Due to space constraints I would like to have the 'hide" button set the visible property of that button to false and the "hide button" to true and visa-versa with the other button. By placing the buttons on top of each other the proper button is always visible and space used is compact. I am new to VB and can't get this to work although I assume it is possible. Suggestions? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I make a command button invisible or visible?
Private Sub cmdHide_Click()
With Me .cmdHide.Visible = False .cmdUnhide.Visible = True .cmdDo1.Visible = False End With End Sub Private Sub cmdUnhide_Click() With Me .cmdHide.Visible = True .cmdUnhide.Visible = False .cmdDo1.Visible = True End With End Sub -- HTH RP (remove nothere from the email address if mailing direct) "Mandora" wrote in message ... I have two command buttons. One hides a range of columns with VB code. One unhides the same range with VB code. Due to space constraints I would like to have the 'hide" button set the visible property of that button to false and the "hide button" to true and visa-versa with the other button. By placing the buttons on top of each other the proper button is always visible and space used is compact. I am new to VB and can't get this to work although I assume it is possible. Suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Make a chart axis visible/invisible with VBA | Charts and Charting in Excel | |||
make button invisible if macros disabled | Excel Discussion (Misc queries) | |||
Check Box to switch make comments visible or invisible | Excel Discussion (Misc queries) | |||
Command Button Always Visible in window | Excel Discussion (Misc queries) | |||
Make Command Button visible only in .xlt? | Excel Programming |