Open Userform Upon Selection in Listbox for Editing

mucah!t

Well-known Member
Joined
Jun 27, 2009
Messages
593
Hi all,

I'd like a Userform to pop-up after selecting an iten from a Listbox and pressing a button.

The Userform should should retrieve the selected item only so I can use it for editing.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Add a ListBox and a CommandButton from the Control Toolbox to your worksheet. Insert a UserForm and add a TextBox. Then try this code:

Code:
'Module for worksheet
 
Private Sub CommandButton1_Click()
    If Me.ListBox1.ListIndex >= 0 Then
        UserForm1.Show
    End If
End Sub
 
'UserForm module
 
Private Sub UserForm_Initialize()
    TextBox1.Text = Worksheets("Sheet1").OLEObjects("ListBox1").Object.Value
End Sub
 
Upvote 0
the data in the listbox is retrieved from range A1:E
When the userform is opened en the value is given in the textbox, i'd like possibility to overwrite that value and, by pressing a button, to update the value.
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,472
Members
452,915
Latest member
hannnahheileen

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