Listbox multi selection

  • Thread starter Thread starter Jorge Rodrigues
  • Start date Start date
J

Jorge Rodrigues

Hi,
I have a lisbox worksheet based:
John
Mario
Maria
Charles

What I want: mark John and Maria and in contiguos cell appear number 1:
A1 B1
John 1

A3 B3
Maria 1

Thanks in advance

Jorge
 
Jorge Rodrigues said:
Hi,
I have a lisbox worksheet based:
John
Mario
Maria
Charles

What I want: mark John and Maria and in contiguos cell appear number 1:
A1 B1
John 1

A3 B3
Maria 1

Not quite sure eactly what you mean. I'm going to guess its:
You have a list of names in a ListBox. Whatever names are selected should
be placed on the sheet in column A, on the row they appear in the listbox.
A 1 should be placed next to them in column B. Which is:

assuming your listbox is called MyList and your worksheet is called
MySheet:

dim r as long

for r = 1 to MyList.ListCount - 1
if MyList.Selected( r) then
Sheets("MySheet").Cells( r, 1).Value = MyList.List(r)
Sheets("MySheet").Cells( r, 2).Value = 1
endif
next


Iain King
 
Hi, Iain:
Thanks for your help. However, the problem is that the names are in the
sheet, I mean from B10:B50 and the ListBox source is from B10:B50. So the
only thing that I want is to choose a name from this list, for example B15
(Jorge) and as I click in that name, it appears in C15 the number 1 and so
on if I click in other names in List. I don't know if I could explain right
away, excuse me, please. Can you be so kind in order to help me again? I
thank you in advance.
Jorge
 
Hi again!
Never mind Iain! I found out what was the problem and now is solved with a
little modifying of your hint:
Dim r As Long

For r = 1 To ListBox1.ListCount - 1

If ListBox1.Selected(r) Then
Sheets("List_Grat").Cells((r + 10), 5).Value = 1
End If
Next
 

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