UserForm vs embedded controls

Rainmanne

Board Regular
Joined
Mar 10, 2016
Messages
120
Office Version
  1. 2013
Platform
  1. Windows
I have a few models which do the same thing but for different sets of data. I am thinking to merge them into one model where a user will have to select a type of the data in order to run either a corresponding sub or a corresponding piece of code in the main sub.

Background: the existing models import data from a spreadsheet generated by a different application. There are two types of the data , which could be presented in two different templates. Also one data type has two subtypes. Also there is an option to replace conditional formatting in the resulted spreadsheet with normal (two avoid issues). So there are currently 4 models and six combinations of the data.

The combined model will have user form controls which will allow a user to select what data type combination they import.

So I first created a userform, which is activated by pressing a button on the spreadsheet. Then I thought that the button redundant. So I am now thinking how to get rid of the button.

I can either use form controls just on the first worksheet of the model. The only issue with it that I have changed the text on each of them and now it's a bit difficult to find their names to refer to in a macro. In the userform on the other hand you can change the names of the controls to something relevant, which makes it much easier to use and change/check the code if necessary. So to bring up the userform I used

VBA Code:
Private Sub Workbook_Open()
    UserForm1.Show
End Sub

But then I thought, if a user would like to unload the userform, they will have to close and reopen the model to re-initialise it. I can put a button to re-initialise it but it will defy the whole reason to remove it.

SO I wonder what is the best way to deal with this situation.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I'd suggest the button to load the form (and possibly the form's controls too) should be on the Ribbon, not a worksheet.
 
Upvote 0
I'd suggest the button to load the form (and possibly the form's controls too) should be on the Ribbon, not a worksheet.
Thanks a lot fo rthe suggestion. But it won't work. I need to have the user form on the sheet either already visible or loading automatically.
 
Upvote 0
You can still use the Workbook_Open code to load it at startup but you presumably need some way to reload it if necessary.
 
Upvote 0
Is there a way to hide a button on the worksheet when the UserForm is up?
 
Upvote 0
Yes, just set its visible property to false.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,398
Messages
6,124,694
Members
449,179
Latest member
kfhw720

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