Change Listbox Item (multicolumn value)

maria90

New Member
Joined
Apr 9, 2012
Messages
38
I have a multicolumn listbox. I would like the user to be able to change the selected value with an input box.

This is the code which I have written so far - with an example value

Code:
Dim intListitem As Integer
intListitem = lstOrders.ListIndex
Me.lstOrders.List(intListitem) = "12.12.2012"

When the user double clicks on an item, the code retrieves the index number.
For a test, I set the code to rewrite the selected item with "12.12.2012".

Here is the problem: The code loops many times until it stops. Why?
My second question is about the column. How do I change the third item only?
With the current code, the value is put into the first column.

The listbox - lstOrders


Code:
¦-----------------¦-----------------¦-----------------¦
¦                 ¦                 ¦                 ¦
¦                 ¦                 ¦                 ¦
¦        0        ¦        1        ¦        2        ¦
¦                 ¦                 ¦                 ¦
¦                 ¦                 ¦                 ¦
¦-----------------¦-----------------¦-----------------¦
¦                 ¦                 ¦                 ¦
¦                 ¦                 ¦                 ¦
¦      ID         ¦       Date      ¦     Customer    ¦
¦                 ¦                 ¦                 ¦
¦                 ¦                 ¦                 ¦
¦-----------------¦-----------------¦-----------------¦

Thanks for your help!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Since your ListBox is 2D, you would need to reference the row,column to change:
Code:
Private Sub lstOrders_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Row As Integer
Dim Col As Integer

'I always want the 3rd column in listbox to be the one updated
Col = 2     'First item = 0

With lstOrders
    Row = .ListIndex
    .List(Row, Col) = "12/12/2012"
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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