Command Botton

roi santos

Board Regular
Joined
Oct 3, 2008
Messages
57
Hi all!
I have a form that show certain frames when a command bottom is clicked.But I havent find a way of making the frame disapear if the command bottom is clicked again. My code is shown below

Private Sub CommandButton1_Click()
Frame1.Visible = True
End Sub
Private Sub CommandButton2_Click()
Frame2.Visible = True
End Sub
Private Sub CommandButton3_Click()
Frame3.Visible = True
End Sub
Private Sub CommandButton4_Click()
Frame4.Visible = True
End Sub
Private Sub CommandButton5_Click()
Frame5.Visible = True
End Sub
Private Sub CommandButton6_Click()
Frame6.Visible = True
End Sub
Private Sub CommandButton7_Click()
Frame7.Visible = True
End Sub

Can somebody help with this?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi,

How about something like this?

Code:
Private Sub CommandButton1_Click()
    Frame1.Visible = Not Frame1.Visible
End Sub
 
Upvote 0
Thanks for your reply

But I do not know how this can do the trick. Probably I havent explained the problem very well.

The commad bottoms will make visible the frames in which I want to add data to. But if I accidentally press the command bottom that show a frame that I do not want to fill, I would like to be able to make it disapear by pressing the command botton again.
 
Upvote 0
Hi,

That is what I posted. Clicking the commandbutton will toggle the frame's visibility on and off. Isn't that what you want?
 
Upvote 0
Colin,

Sorry about the confusion. Yes, it does exactly what you say and exacly what I wanted.

I was adding your code after in this way

Private Sub CommandButton1_Click()
Frame1.Visible
Frame1.Visible = Not Frame1.Visible
End Sub

And this oviously do not work. It should read

Private Sub CommandButton1_Click()
Frame1.Visible = Not Frame1.Visible
End Sub

Thanks for your help.Sorry for my mistake
 
Upvote 0

Forum statistics

Threads
1,215,584
Messages
6,125,670
Members
449,248
Latest member
wayneho98

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top