User form code for unload me when Title bar is removed

lady_alina

Board Regular
Joined
Feb 18, 2015
Messages
52
Hi,

I have a user form where I have used the below code to remove the title bar but the problem is the unload me sub doesn't work. Can somebody help with the code for user form load me button. Also if soembody can help me with the code to auto populate some of the text boxes based on the combo box.

Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long _
, ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long

Code:
Private Sub UserForm_Initialize()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84080080&
DrawMenuBar hWnd
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Can you give an example of a userform that exhibits this behaviour. "Unload Me" works fine for me
 
Upvote 0
Thanks for the reply... Yes I did try the code given below, but looks liek it takes forever when I click on it in the user form.

Code:
Private Sub COMMANDBUTTON1_Click()

Unload Me


End Sub
 
Upvote 0
Unloading a UserForm should not take long. What else is happening/

Can you upload the file to OneDrive, DropBox or similar then provide a download link here?
 
Upvote 0
Thanks RoyUK I modified the userform code for auto populating text box and its working perfectly. I'm just facing one problem that is the combo box is also showing the header in the drop down, I tried to change the below line but it doesn't really help.

Code:
Me.ComboBox1.List = Sheet1.Cells(1, 1).CurrentRegion.Value

to

Code:
Me.ComboBox1.List = Sheet1.Cells(2, 2).CurrentRegion.Value

Also the above code which i used for removing the title bar, could that be used with the user form initialize sub you gave, if yes will you be able to help me with it. Sorry I am very new to VBA.

The unload button is working perfectly now. I guess there was some problem in my excel or system..
 
Upvote 0
Change it to

Code:
Me.ComboBox1.List = Sheet1.Cells(1, 1).CurrentRegion.Offset(1).Value
 
Upvote 0
Where does the actual list start?

Can you upload an example userform to a file sharing site like OneDrive or DropBox then post a link here
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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