View Single Post
  #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?
.