[HELP] Listbox in Excel Userform

excelrocking

New Member
Joined
Oct 8, 2010
Messages
11
Hi guys! I need help in populating my listbox with values from a worksheet.

EXCEL.jpg


Here's the userform:
vba2.jpg


And also, can you teach me how to ADD, EDIT, and DELETE selected items on the listbox.
In a way that it'll be added, edited, and deleted in both the listbox and worksheet.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Code:
Private Sub UserForm_Initialize()
lb1.ColumnCount = 5
Dim myArray(6, 5) As Integer
For i = 1 To 5
    For j = 1 To 5
        myArray(i - 1, j - 1) = Cells(i+1, j)
    Next j
Next i
lb1.List() = myArray
End Sub

Paste this in the initialize event of your userform. Umay need to modify the code a bit.

lb1 is the name of my listbox.
 
Upvote 0
Code:
Private Sub CommandButton1_Click()
   lb1.RemoveItem (lb1.ListIndex)
End Sub

Use this to remove selected item from the list.
 
Upvote 0

Forum statistics

Threads
1,215,424
Messages
6,124,817
Members
449,190
Latest member
rscraig11

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