Multiple Output from Listbox

  • Thread starter Thread starter idoru
  • Start date Start date
I

idoru

Can anyone help?!

I have a listbox with four options set up so multiple choices ar
allowed. I would like output in a seperate sheet that records which o
the options are selected.
So if the options were 1-4 I would like four columns in my output shee
with 1s and 0s or TRUEs and FALSEs for each option.

Can this be done
 
What you want shouldn't be that hard. Was your listbox inserted fro
the Control Toolbar or the Forms Toolbar? How are you planning o
submitting your selections....Will you click on a submit button or d
you want the event to happen when the listbox loses focus? Here is som
sample code that checks for selected values of *1, 2, 3, 4* in th
listbox and places *True* in cells A1, B1, C1, D1 respectively if the
are selected. In toolbar design mode, right click your listbox an
select *VIEW CODE* and copy and paste this code into the module. Mak
sure to change the cases to reflect what appears in your listboxes an
make sure to change the name of the listbox so it matches the name o
yours.


Code
-------------------

Private Sub ListBox1_LostFocus()

For i = 0 To ListBox1.ListCount - 1

If ListBox1.Selected(i) = True Then

Select Case ListBox1.List(i)

Case 1

Range("A1").Value = "True"

Case 2

Range("B1").Value = "True"

Case 3

Range("C1").Value = "True"

Case 4

Range("D1").Value = "True"

End Select

End If


Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top