Hiding a Command Button

HardAtWork

Board Regular
Joined
Sep 17, 2010
Messages
52
This question stems from my lack of ability to make a code work in 2003, but it work in 2007. See my other post about the code if you think you may be able to help.

If I can't figure that problem out I though I could hide the command button based upon the excel version the user is using.

Question. I created a user form that has two buttons one day mode and one night mode. When activated they change the font and other items in the workbook.

Is it possible to hide the two buttons that are on a user form if the user is using 2003 only, but show them if the user is on 2007?

If the answer is yes how would I go about writing the code for the change?

Thank You.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Something like this?
Rich (BB code):

Private Sub UserForm_Initialize()
  If Val(Application.Version) < 12 Then
    CommandButton1.Visible = False  ' or CommandButton1.Enabled = False
    CommandButton2.Visible = False  ' or CommandButton2.Enabled = False
  End If
End Sub
 
Upvote 0
This coding works fine if I put the code in the box I want to disappear.

This is how my code work (Forgive my break down)

Options Button

User Form Opens with two button called "Day" "Night" on the form

If I put the above code with in the button called Day or Night it works; however, I need the code to be in the options button that way the user never sees the day or night button when the user form is open.

With my options button I have the code the activate the user form as following:

Private Sub ShowOptions_Click()

FormParameter.show

End Sub

If I put the above coding before are after the .show code it tells me I need an object.

Any idea of getting around this?
 
Upvote 0
Okay I tried it many different ways and can not get it to work, but the code provided is good.

Not sure what else to try.

I don't understand why I can add the code within the button that opens the user form and have it work?

It works when I put the same code under the button I want to disappear; however, it will not disappear until they click on it...which is not what I want.

I guess I'll sleep on it and work on it tomorrow.
 
Upvote 0
Please post your relevant code and describe where the option buttons are (on UserForm or in Sheet), what is an issue and what is scenario to cause that issue.
At which moment you need in hiding of Excel application: at workbook loading, at UserForm activating or at clicking of the button?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

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