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: 1
Default listbox works in form; not imbedded???

I have a set set of four list boxs that needs to be populated with
list from one of 36 columns....9 main areas, each with fou
sub-columns...User selects 1-9, and then four list boxes are populate
from the four sub-columns that belongs to that main area....e.g.
select 2, then Excel gets the four sub-columns that belong to item
and drops them into four listboxes.

The user selects 1-9 from a combobox.

I use a series of offsets to tell Excel the location of the column t
populate the listboxes.

The following code works fine when I use a list box in a form.
However, I need the code to work when the list box is embedded i
Sheet1. I get a "1004" error everytime I run the macro, and it say
"method 'Range' of Object_worksheet failed.

What am I doing wrong?

Here is the code:
______________________

Sub worksheet_activate()
mainlist = Sheet4.Range("threads") 'the names of the 9 columns
Sheet1.ComboBox1.List = mainlist
End Sub

Private Sub ComboBox1_Change()
'
Dim clericallist As Variant
Dim mechlist As Variant
Dim proactivelist As Variant
Dim worldclasslist As Variant
'
' Following Section uses the term "base" to refer to the
' Column number of the main area
' Add 1 to the base and you get the items for sub-column 1
' Add 2 to the base and you get the items for sub-column 2, etc.
If Sheet1.ComboBox1.ListIndex = 0 Then base = 1
If Sheet1.ComboBox1.ListIndex = 1 Then base = 6
If Sheet1.ComboBox1.ListIndex = 2 Then base = 11
If Sheet1.ComboBox1.ListIndex = 3 Then base = 16
If Sheet1.ComboBox1.ListIndex = 4 Then base = 21
If Sheet1.ComboBox1.ListIndex = 5 Then base = 26
If Sheet1.ComboBox1.ListIndex = 6 Then base = 31
If Sheet1.ComboBox1.ListIndex = 7 Then base = 36
If Sheet1.ComboBox1.ListIndex = 8 Then base = 41
If Sheet1.ComboBox1.ListIndex = 9 Then base = 46
'
' At the top of each column is a count of the numner of items
' in the list. The next section grabs that count number and
' adds three (because the lists start in row 3) to determine the
' location of the bottom cell in the list....
clericallength = Sheet3.Range("A1").Offset(0, base + 1).Value + 3
'mechanicallength = Sheet3.Range("A1").Offset(0, base + 2).Value + 3
'proactivelength = Sheet3.Range("A1").Offset(0, base + 3).Value + 3
'worldclasslength = Sheet3.Range("A1").Offset(0, base + 4).Value + 3
'
'
' ERROR EXISTS IN THIS SECTION <<<<<<<<<
' This section defines the range of the list....
' The first "Cells(3,Base+2)" tells Excel the top cell of the list
' the second "Cells (clericallength, base+2)" tells Excel the bottom
' cell in the list
clericallist = Sheet3.Range(Cells(3, base + 2), Cells(clericallength
base + 2))
'mechlist = Sheet3.Range(Cells(3, base + 3), Cells(mechanicallength
base + 3))
'proactivelist = Sheet3.Range(Cells(3, base + 4)
Cells(proactivelength, base + 4))
'worldclasslist = Sheet3.Range(Cells(3, base + 5)
Cells(worldclasslength, base + 5))
'
'
' This section populates the listboxes with the appropriate lists
Sheet1.mainclericalbox.List = clericallist
'Sheet1.mainmechanicalbox.List = mechlist
'Sheet1.mainproactivebox.List = proactivelist
'Sheet1.mainworldclassbox.List = worldclasslist


End Su

--
Message posted from http://www.ExcelForum.com

 
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
How to filter listbox data in a form? Vinod Excel Discussion (Misc queries) 1 January 11th 10 02:01 PM
Multi-field listbox in an Excel form Lee S. Excel Discussion (Misc queries) 0 September 14th 06 10:19 PM
listbox option in form inquirer Excel Programming 2 April 7th 04 02:16 AM
User form with a listbox John Green[_2_] Excel Programming 4 December 30th 03 07:18 PM
Listbox/Form question Stuart[_5_] Excel Programming 1 August 24th 03 04:53 PM


All times are GMT +1. The time now is 03:57 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"