Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a chart axis visible/invisible with VBA Jeff Reese Charts and Charting in Excel 3 April 27th 23 03:42 AM
make button invisible if macros disabled Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 0 November 29th 07 08:43 PM
Check Box to switch make comments visible or invisible DanHegarty Excel Discussion (Misc queries) 1 June 10th 06 04:08 PM
Command Button Always Visible in window avveerkar Excel Discussion (Misc queries) 2 January 11th 06 12:21 PM
Make Command Button visible only in .xlt? RPIJG[_23_] Excel Programming 2 May 17th 04 07:14 PM


All times are GMT +1. The time now is 08:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"