How to Create a Modeless Form VBA

wcm69

Board Regular
Joined
Dec 25, 2016
Messages
112
I have the below code in my workbook module and I'd like to make it modeless so I can work in the active spreadsheet while it is also active. I want it to also stay visible and active through out (i.e. as long as I'm in a particular spreadsheet) because I've put Command Buttons on the form to navigate between worksheets - of which there are 51.

I should mention the code I'm using positions the Form and hides the [x] Close button and Title bar.

Any help would be greatly appreciated.

Thanks in advance :)

Code being used:

Private Sub UserForm_Activate()

Me.StartUpPosition = 0
Me.Top = Application.Top + 170
Me.Left = Application.Left + Application.Width - Me.Width - 40

End Sub

Private Sub UserForm_Initialize()
HideTitleBar Me

End Sub
 
Again, I'm hoping the above is clear and someone can provide a code/s (with a few instruction) that will do the trick.

Thanks in advance :)

this code is untested ( i would need to set up workbook with some userformS to test it)

this is best i can come up with to give you basic code that could be easily modified for each sheet you should only need to change the last line on each sheet to give it that sheets userform name

it will unload any open userforms and then open the userform for that sheet, this is not a flexible as the hide method as unload clears the forms current entries

Code:
Private Sub Worksheet_Activate()

'UnloadAllForms()
Dim frm As UserForm

  For Each frm In UserForms

     Unload frm

  Next frm

' Load UserForm for this sheet

UserForm1.Show

End Sub
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
This poster has now started another thread on this same forum on this same subject here:

https://www.mrexcel.com/forum/excel...ple-worksheets-visual-basic-applications.html


this code is untested ( i would need to set up workbook with some userformS to test it)

this is best i can come up with to give you basic code that could be easily modified for each sheet you should only need to change the last line on each sheet to give it that sheets userform name

it will unload any open userforms and then open the userform for that sheet, this is not a flexible as the hide method as unload clears the forms current entries

Code:
Private Sub Worksheet_Activate()

'UnloadAllForms()
Dim frm As UserForm

  For Each frm In UserForms

     Unload frm

  Next frm

' Load UserForm for this sheet

UserForm1.Show

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,946
Messages
6,181,945
Members
453,074
Latest member
JefersonKollet

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