The Grim Discovery

Board Regular
Joined
Jan 23, 2015
Messages
244
Office Version
  1. 365
Platform
  1. Windows
Hi Excel peoples

I'm using a Listbox which contains three selectable items - the idea being that people can select any number/combination of the three as they see fit. It works fine but the linked cell reports '0' when more than 1 item on the listbox is selected. I've read around and the only answer seems to be use VBA which I dont understand and makes my brain hurt.

Is there a quick fix for this or an alternative that anybody would recommend? The key features being that any permutation of the three must be selectable and that whatever is picked can be counted easily.

Thanks in advance for your time & willingness to share knowledge.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
for multi pick lists, you have to scan the entire list to determine what is selected....

Rich (BB code):
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True  Then msgbox ListBox1.List(i)
Next i
 
Last edited:
Upvote 0
What you are looking for is difficult with Forms ListBoxes.
Three checkboxes might be better.

If you need to use a listbox, you could put this as the control's Assigned Macro
Code:
Sub ListBox1_Change()
    Dim CheckedSum As Long, i As Long
    With ActiveSheet.Shapes("List Box 1").OLEFormat.Object
        For i = 1 To .ListCount
        CheckedSum = CheckedSum - ((2 ^ (i - 1)) * .Selected(i))
        Next i
    End With
    Range("B1").Value = CheckedSum
End Sub
It will put a number in B1 that represents which items on the list are checked
0- no checked
1- item 1 checked
2 - item 2 checked
3- items 1 and 3 checked
4 - item 3 checked
5 - items 1 and 3 checked
6 - items 2 and 3 checked
7 - items 1, 2 and 3 checked

etc.

(think of numbers in binary 010 means item 2 checked)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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