ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox multi selection (https://www.excelbanter.com/excel-programming/309152-listbox-multi-selection.html)

Jorge Rodrigues

Listbox multi selection
 
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



Iain King

Listbox multi selection
 
"Jorge Rodrigues" wrote in message
...
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



Jorge Rodrigues

Listbox multi selection
 
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
"Iain King" escreveu na mensagem
...
"Jorge Rodrigues" wrote in message
...
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





Jorge Rodrigues

Listbox multi selection
 
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

"Jorge Rodrigues" escreveu na mensagem
...
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
"Iain King" escreveu na mensagem
...
"Jorge Rodrigues" wrote in message
...
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








All times are GMT +1. The time now is 08:55 AM.

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