User Forms

antman123

Board Regular
Joined
Jan 24, 2005
Messages
72
Hi. I have a user form that is activated when a user selects a name from a drop down menu bar. At the moment, the user selects a name from the drop down menu and then has to click an EDIT button i created to trigger the userform. What i would like is to get rid of this button and have the userform automatically appear when a new name is selected.

I tried this by creating a function that is called each time the name changes. This worked, but when the userform comes up, you cant edit the persons details (by pressing the edit button on the userform) Becasue i think the function ends. Here is the code i made. At the moment the userform pops up as planned, but when you press the edit button, nothing happens. Thanks for your time.

Function autoClick(name)
Unload UserForm1
Load UserForm1
Set tableRange = ThisWorkbook.Worksheets("User Info").Range("C1:K93")
personname = ThisWorkbook.Worksheets("User Info").Range("M2").Value
With UserForm1
.Name1.Value = personname
.DeskNo.Value = WorksheetFunction.VLookup(personname, tableRange, 2)
.ExtNo.Value = WorksheetFunction.VLookup(personname, tableRange, 3)
.TelID.Value = WorksheetFunction.VLookup(personname, tableRange, 4)
.Serial.Value = WorksheetFunction.VLookup(personname, tableRange, 5)
.ID.Value = WorksheetFunction.VLookup(personname, tableRange, 6)
.GID.Value = WorksheetFunction.VLookup(personname, tableRange, 7)
.Show
End With
autoClick = ThisWorkbook.Worksheets("User Info").Range("m2").Value
End Function
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,731
Messages
6,126,539
Members
449,316
Latest member
sravya

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