making userform objects not visible on startup

spalton

Board Regular
Joined
Feb 20, 2009
Messages
125
Hi there,

My first day trying to work out visual Basic!

I've got a number of objects laid out on my userform, but some of them need to be invisible before a button in pressed.

I need it to hide the labels, other buttons etc on startup everytime the workbook is opened.

I've tried the following code just in the workbook-open function but it isn't working? is it because I need to reference the userform in someway?

Private Sub Workbook_Open()
ActiveWorkbook.Sheets("working").Activate
Range("c3:c5").Value = "NA"
Range("c8:c12").Value = "NA"
Range("c15:c19").Value = "NA"
Range("c25:c27").Value = "NA"
the above all work fine
label16.visible = false does not work
End Sub

How do I reference the userform?

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You need to put the label16 on a form. Within VB to go Insert and select form. Drag your label onto the form (which will be Userform1 by default).

This will be hidden and you can display Userform1 with :-

Userform1.Show

to hide it :-

Userform1.Hide.

Thks

Kaps
 
Upvote 0
Yep, got that working, with the label16 on the form, problem is only certain things on the form need to be hidden, others need to remain visible.

Can i isolate specific objects in the form to be hidden at startup?
 
Upvote 0
I don't think you can. My only suggestion would to have several forms (userform1, Userform2 etc) and show them when necessary. Thks

Kaps
 
Upvote 0

Forum statistics

Threads
1,203,610
Messages
6,056,294
Members
444,855
Latest member
archadiel

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