ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox with text & input row (https://www.excelbanter.com/excel-programming/359153-listbox-text-input-row.html)

JWM6[_8_]

Listbox with text & input row
 

Is it possible to create a listbox that has text (description) and an
input (number) in the same row?

Shirts X
Shoes X
Pants X

This way I can list the items, scroll to the item and input a number
("X").

Thanks!


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=533816


Kletcho

Listbox with text & input row
 
You can only do that on a userform listbox and not through the forms
toolbar. Here is some code that should help you out:

Private Sub UserForm_Initialize()
Dim strArray As Variant

strArray = Array("Shirt", "Pants", "Shorts", "Sweater", "Socks")
With Me.ListBox1
.ColumnCount = 2
.ColumnHeads = False
For i = 1 To 5
.AddItem i
.List(.ListCount - 1, 1) = strArray(i - 1)
Next i
.ColumnWidths = "20;50"
End With
End Sub


JWM6[_9_]

Listbox with text & input row
 

Thanks. That was close and helps me better understand how I can
populate a listbox. I can see I wasn't explaining myself as well as I
may have...

What I'm looking for is to be able to display text ("Shirts", "Shoes",
"Pants") and allow input (allow me to click and type in a number) in a
single row in a list box. Similarily the list...

Shirts 0
Shoes 0
Pants 0

would allow me to click on the zero next to "Shirts" and type in the
number 10. Then click on the zero next to "Pants" and type in the
number 5.

resulting in...

Shirts 10
Shoes 0
Pants 5

So the first column is a text field and the second column is an input
(Numeric) field.

Is this possible?


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=533816


Kletcho

Listbox with text & input row
 
You can't do this through a list box, as a list box only allows you to
list things and then select one or many. The only object that lets you
type in a value is the text box. You could use a number of labels and
line them up with text boxes, and then enter the value of the label to
be "shirt", "pants", etc. Can I ask why you are trying to do this
through objects versus just having a few cells in a worksheet where you
list "shirt", "pants", etc and then have the cells next to them be
where you enter the quantity?


JWM6[_10_]

Listbox with text & input row
 

I figured the listbox was just for listing stuff...

I need to do this in a form and have LOTS of items, which may vary,
that I need to display. I found some code where I can click on the
listbox item, then display the item name and default value (using
InputBox), allow the value to be changed, the plunk it back in the
correct column when the InputBox is dismissed with the OK button.
Serves the purpose.

Thanks for your help & responses.


--
JWM6
------------------------------------------------------------------------
JWM6's Profile: http://www.excelforum.com/member.php...o&userid=33413
View this thread: http://www.excelforum.com/showthread...hreadid=533816



All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com