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
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