LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Adding selected items from one list box to two different list boxe


I created a userform, also have made three list boxes

List box 2 contains a default list of 10 companies I want selected, I want
the user to select two companies from here. Then the values (stored in
sheet.1 range) for the 1st company dropped into List box 3 and the other into
List box 4.

Currently, I am receiving a runtime error message '9' saying 'subscript out
of range'. please can someone help me sort this out. I pasted the relevant
part of the code below (I know am an amature VBA programmer). Thank you as I
await a response








Dim numofStock As Integer, daily As Integer, countSelected As Integer,
countSelectedi As Integer, countSelectedii As Integer
Dim column As Integer, row As Integer, i As Integer, j As Integer, k As
Integer, L As Integer
Dim SelectedStocki() As Variant, Stock() As Variant, SelectedStockii() As
Variant

numofStock = 10
daily = 1283
countSelectedi = 0
countSelectedii = 0

ReDim SelectedStocki(1 To daily, 1 To numofStock), Stock(1 To daily, 1 To
numofStock)
ReDim SelectedStockii(1 To daily, 1 To numofStock), Stock(1 To daily, 1 To
numofStock)

Stock = Sheet1.Range("Returns").Value

For column = 0 To numofStock - 1
If ListBox2.Selected(column) = True Then
countSelected = countSelectedi
countSelected = countSelectedii
Selection(countSelectedi) = ListBox2.List(column)
Selection(countSelectedii) = ListBox2.List(column)
For row = 1 To daily
SelectedStocki(row, countSelectedi) = Stock(row, column + 1)
Next row
For row = 1 To daily
SelectedStockii(row, countSelectedii) = Stock(row, column + 1)
Next row
End If
Next column
'Next column

ReDim Preserve SelectedStocki(1 To daily, 1 To countSelectedi)
ReDim Preserve SelectedStockii(1 To daily, 1 To countSelectedii)

With ListBox3
For j = 1 To countSelectedi
For i = 1 To daily
.AddItem Stock(i, j)
Next i
Next j
End With

With ListBox4
For k = 1 To countSelectedii
For L = 1 To daily
.AddItem Stock(k, L)
Next L
Next k
End With
 
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
List and subtotal selected items, then print separate item list TitanG Excel Worksheet Functions 0 September 8th 08 09:07 PM
Filtering using multiple selected items in a list box snowiii Excel Programming 0 August 21st 08 07:38 PM
Feed Multiple Comb Boxe with same list ExcelMonkey Excel Programming 0 January 25th 08 09:29 PM
How do i find items selected in a list box ? Listbox use in Excel Excel Programming 7 June 30th 05 09:25 PM
named range, data validation: list non-selected items, and new added items KR Excel Discussion (Misc queries) 1 June 24th 05 05:21 AM


All times are GMT +1. The time now is 11:13 PM.

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"