Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default trouble with a listindex value...

Help!

Using XL 2000, I'm trying to assign and show a listindex
value to an item selected in the list.
Although the procedure is relatively simple, I have added
the code i'm currently using to help explain what is going
on.

I have a listbox on userform1 which is populated thus:

ListBox1.Clear
With ListBox1
.RowSource = "Info!A1:A12"
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

I can then scroll through the listbox which contains 16
items to select one or many. When selected, I need the
listindex value to be appended to a list (assuming more
than one item is selected) which is then displayed in the
worksheets activecell.

The following does not quite fulfil this requirement as
the active cell only appends the previous listindex value.
if items 1,3,5,9 were selected (or at least their
equivelant listbox text, activell shows 9,9,9,9 - the
previous 3 were overwritten.

Private Sub ListBox1_Change()
SelectedQA = ""
With ListBox1
For iCt = 0 To .ListCount - 1
If .Selected(iCt) = True Then _
SelectedQA = SelectedQA & .ListIndex + 1
_& ", "
Next iCt
End With

If Len(SelectedQA) 0 Then _
SelectedQA = Left(SelectedQA, Len(SelectedQA))
ActiveCell = SelectedQA '
End Sub

I hope this explains my problem.
Any solutions/guidance appreciated.

Thanks, Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default trouble with a listindex value...

Change

SelectedQA = SelectedQA & .ListIndex + 1

to

SelectedQA = SelectedQA & iCt + 1

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Paul" wrote in message
...
Help!

Using XL 2000, I'm trying to assign and show a listindex
value to an item selected in the list.
Although the procedure is relatively simple, I have added
the code i'm currently using to help explain what is going
on.

I have a listbox on userform1 which is populated thus:

ListBox1.Clear
With ListBox1
.RowSource = "Info!A1:A12"
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

I can then scroll through the listbox which contains 16
items to select one or many. When selected, I need the
listindex value to be appended to a list (assuming more
than one item is selected) which is then displayed in the
worksheets activecell.

The following does not quite fulfil this requirement as
the active cell only appends the previous listindex value.
if items 1,3,5,9 were selected (or at least their
equivelant listbox text, activell shows 9,9,9,9 - the
previous 3 were overwritten.

Private Sub ListBox1_Change()
SelectedQA = ""
With ListBox1
For iCt = 0 To .ListCount - 1
If .Selected(iCt) = True Then _
SelectedQA = SelectedQA & .ListIndex + 1
_& ", "
Next iCt
End With

If Len(SelectedQA) 0 Then _
SelectedQA = Left(SelectedQA, Len(SelectedQA))
ActiveCell = SelectedQA '
End Sub

I hope this explains my problem.
Any solutions/guidance appreciated.

Thanks, Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default trouble with a listindex value...

Thank you.could not see the wood for the trees!

Paul


-----Original Message-----
Change

SelectedQA = SelectedQA & .ListIndex + 1

to

SelectedQA = SelectedQA & iCt + 1

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros

for Excel

"Paul" wrote in

message
...
Help!

Using XL 2000, I'm trying to assign and show a listindex
value to an item selected in the list.
Although the procedure is relatively simple, I have

added
the code i'm currently using to help explain what is

going
on.

I have a listbox on userform1 which is populated thus:

ListBox1.Clear
With ListBox1
.RowSource = "Info!A1:A12"
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

I can then scroll through the listbox which contains 16
items to select one or many. When selected, I need the
listindex value to be appended to a list (assuming more
than one item is selected) which is then displayed in

the
worksheets activecell.

The following does not quite fulfil this requirement as
the active cell only appends the previous listindex

value.
if items 1,3,5,9 were selected (or at least their
equivelant listbox text, activell shows 9,9,9,9 - the
previous 3 were overwritten.

Private Sub ListBox1_Change()
SelectedQA = ""
With ListBox1
For iCt = 0 To .ListCount - 1
If .Selected(iCt) = True Then _
SelectedQA = SelectedQA & .ListIndex + 1
_& ", "
Next iCt
End With

If Len(SelectedQA) 0 Then _
SelectedQA = Left(SelectedQA, Len

(SelectedQA))
ActiveCell = SelectedQA '
End Sub

I hope this explains my problem.
Any solutions/guidance appreciated.

Thanks, Paul



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform problem (Listindex) jgmiddel Excel Discussion (Misc queries) 1 April 26th 06 01:34 PM
listindex Steph[_3_] Excel Programming 1 June 25th 04 06:14 PM
ListIndex Todd Huttenstine Excel Programming 2 May 13th 04 04:21 PM
Use ListIndex to set Sheet order? Stuart[_5_] Excel Programming 2 February 20th 04 01:22 PM
ListIndex = cell value? Christy[_2_] Excel Programming 1 September 20th 03 03:19 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"