Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Listbox


Hi All,

I have created a Listbox on a Userform. the Listbox properties are a
folows:

Name: SectorList
MultiSelect: fmMultiSelectMulti

I am trying to see which items were selected and then for these items
want to put their value into a cell. My problem is that once it find
the first item that was selected, it puts its value into the relevan
cell but then seems to mark all the other selected items as no
selected.

The weird thing is, for testing purposes, if i dont actually assign th
selected items value to a cell then there is no problems!

The code is as follows:

For lItem = 0 To sectorList.ListCount - 1
If sectorList.Selected(lItem) Then
ActiveCell.Value = sectorList.List(lItem)
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Next

Any help would be really appreciated!

Shakee

--
shakeel_sadi
-----------------------------------------------------------------------
shakeel_sadiq's Profile: http://www.excelforum.com/member.php...fo&userid=3576
View this thread: http://www.excelforum.com/showthread.php?threadid=55538

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Excel VBA Listbox

Your code works as expected for me.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"shakeel_sadiq"

wrote in message
news:shakeel_sadiq.29yzio_1151259002.8718@excelfor um-nospam.com...

Hi All,

I have created a Listbox on a Userform. the Listbox properties
are as
folows:

Name: SectorList
MultiSelect: fmMultiSelectMulti

I am trying to see which items were selected and then for these
items i
want to put their value into a cell. My problem is that once it
finds
the first item that was selected, it puts its value into the
relevant
cell but then seems to mark all the other selected items as not
selected.

The weird thing is, for testing purposes, if i dont actually
assign the
selected items value to a cell then there is no problems!

The code is as follows:

For lItem = 0 To sectorList.ListCount - 1
If sectorList.Selected(lItem) Then
ActiveCell.Value = sectorList.List(lItem)
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Next

Any help would be really appreciated!

Shakeel


--
shakeel_sadiq
------------------------------------------------------------------------
shakeel_sadiq's Profile:
http://www.excelforum.com/member.php...o&userid=35764
View this thread:
http://www.excelforum.com/showthread...hreadid=555386



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA Listbox


Thanks for checking it Chip

Ive ended up creating a temporary listbox and adding the selected
values into it then reading of this new userlist.

so the problem is solved though as youve said, there shouldnt have been
one! :(

Ta.


--
shakeel_sadiq
------------------------------------------------------------------------
shakeel_sadiq's Profile: http://www.excelforum.com/member.php...o&userid=35764
View this thread: http://www.excelforum.com/showthread...hreadid=555386

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 listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
avoiding duplicates in listbox (added from another listbox) KR Excel Programming 4 March 14th 06 08:17 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 10:39 AM.

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

About Us

"It's about Microsoft Excel"