stirlingmw1
Board Regular
- Joined
- Jun 17, 2016
- Messages
- 53
- Office Version
- 2016
- 2013
- 2010
- 2007
- Platform
- Windows
Good Morning
I have a worksheet "Uplift" on which I have a Data Validation list of "Item" in Cell "B3" and "Qty" in cell "D3". I also have a ActiveX Listbox1.
I have the following code which I hoped would work but it only that adds the selected "Item" to the ListBox1 and not both Item and Qty. The code to remove the selected item below it works too. What I am having trouble with is adding the "Qty" as a second column in the ListBox1. I have the ListBox ColumnCount set to 2.
Any ideas
Thanks
Steve
I have a worksheet "Uplift" on which I have a Data Validation list of "Item" in Cell "B3" and "Qty" in cell "D3". I also have a ActiveX Listbox1.
I have the following code which I hoped would work but it only that adds the selected "Item" to the ListBox1 and not both Item and Qty. The code to remove the selected item below it works too. What I am having trouble with is adding the "Qty" as a second column in the ListBox1. I have the ListBox ColumnCount set to 2.
VBA Code:
Sub AddItems()
Application.ScreenUpdating = False
Sheets("Uplift").ListBox1.ColumnCount = 2
Sheets("Uplift").ListBox1.ColumnWidths = "200;60"
Item = Sheets("Uplift").Range("B3")
qty = Sheets("Uplift").Range("D3")
If Len(Item) > 0 Then Sheets("Uplift").ListBox1.AddItem (Item) & (qty)
Application.ScreenUpdating = True
End Sub
Sub RemoveItems()
If Sheets("Uplift").ListBox1.ListIndex >= 0 Then
Sheets("Uplift").ListBox1.RemoveItem Sheets("Uplift").ListBox1.ListIndex
End If
End Sub
Any ideas
Thanks
Steve