Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default ComboBox processing error

Can someone please help me with the following? I want the contents of a 'Regions' ComboBox to subset the possible choices in a second Combobox. I get a 1004 error relating to the DropDown variable...

Thanks,
Jim Berglund
__________________________________________________ _______________________
Private Sub ComboBox1_Change()
Dim drpdwn As DropDown
With ActiveSheet
Set drpdwn = .DropDowns(Application.Caller)
Select Case drpdwn.ListIndex
Case "All"
' no selection, do nothing
Case 1
' Item1 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 127), .Cells(4, 127))
Case 2
' item2 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 128), .Cells(4, 128))
Case 3
' item3 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 129), .Cells(4, 129))
Case 4
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 130), ..Cells(4, 130))
Case 5 To 14
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 131), ..Cells(4, 131))
End Select
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default ComboBox processing error

I don't know if this is the whole problem but you have "DropDowns" in the "Set" line instead of "DropDown".
"Jim Berglund" wrote in message news:FYPld.223323$%k.58948@pd7tw2no...
Can someone please help me with the following? I want the contents of a 'Regions' ComboBox to subset the possible choices in a second Combobox. I get a 1004 error relating to the DropDown variable...

Thanks,
Jim Berglund
__________________________________________________ _______________________
Private Sub ComboBox1_Change()
Dim drpdwn As DropDown
With ActiveSheet
Set drpdwn = .DropDowns(Application.Caller)
Select Case drpdwn.ListIndex
Case "All"
' no selection, do nothing
Case 1
' Item1 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 127), ..Cells(4, 127))
Case 2
' item2 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 128), ..Cells(4, 128))
Case 3
' item3 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 129), ..Cells(4, 129))
Case 4
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 130), ..Cells(4, 130))
Case 5 To 14
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 131), ..Cells(4, 131))
End Select
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default ComboBox processing error

It also looks like the combobox was created from the control toolbox toolbar.

If you replace that combobox with a dropdown from the Forms toolbar and move
your code into a general module, does it work?

Also, the .listindex will always be a number--never "All".



Jim Berglund wrote:

Can someone please help me with the following? I want the contents of a
'Regions' ComboBox to subset the possible choices in a second Combobox. I get
a 1004 error relating to the DropDown variable...

Thanks,
Jim Berglund
__________________________________________________ _______________________
Private Sub ComboBox1_Change()
Dim drpdwn As DropDown
With ActiveSheet
Set drpdwn = .DropDowns(Application.Caller)
Select Case drpdwn.ListIndex
Case "All"
' no selection, do nothing
Case 1
' Item1 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 127), .Cells(4, 127))
Case 2
' item2 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 128), .Cells(4, 128))
Case 3
' item3 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 129), .Cells(4, 129))
Case 4
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 130), .Cells(4, 130))
Case 5 To 14
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 131), .Cells(4, 131))
End Select


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default ComboBox processing error

Thanks, I tried your suggestions, but didn't get the results I wanted. I've used forms in the past, but was trying something different. However, I did come up with a visual, but less elegant approach, using if statements that does give me the cascading effect I was looking for. (Shown below...)

Private Sub ComboBox4_Change() 'Supertype
Dim sX As Variant
Application.ScreenUpdating = False

With ActiveSheet
.Range("DP5:DP200").Clear
sX = .Range("CB3").Text
i = 5

If sX = Range("CX20").Value Then
Else
If sX = Range("CY20").Text Then
While .Cells((i + 16), 103).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 103).Value
i = i + 1
Wend
Else
If sX = Range("CZ20").Text Then
While .Cells((i + 16), 104).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 104).Value
i = i + 1
Wend
Else
If sX = Range("DA20").Text Then
While .Cells((i + 16), 105).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 105).Value
i = i + 1
Wend
Else
If sX = Range("DB20").Text Then
While .Cells((i + 16), 106).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 106).Value
i = i + 1
Wend
Else
If sX = Range("DC20").Text Then
While .Cells((i + 16), 107).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 107).Value
i = i + 1
Wend
Else
If sX = Range("DD20").Text Then
While .Cells((i + 16), 108).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 108).Value
i = i + 1
Wend
End If

End If
End If
End If
End If
End If
End If
End With

End Sub
It creates a list which will be used as the ListFillRange for the second combobox. I'd appreciate more detailed suggestions for a simpler approach, if you feel this is just too ungainly.

FYI, This is a massive data management project that I'm (independently) working on to handle equipment replacement decisions for large fleets based on fleet asset and maintenance history. The data is collected and massaged using Cognos, but the detailed operations are done in Excel.

Regards,
Jim Berglund

"Dave Peterson" wrote in message ...
It also looks like the combobox was created from the control toolbox toolbar.

If you replace that combobox with a dropdown from the Forms toolbar and move
your code into a general module, does it work?

Also, the .listindex will always be a number--never "All".



Jim Berglund wrote:

Can someone please help me with the following? I want the contents of a
'Regions' ComboBox to subset the possible choices in a second Combobox. I get
a 1004 error relating to the DropDown variable...

Thanks,
Jim Berglund
__________________________________________________ _______________________
Private Sub ComboBox1_Change()
Dim drpdwn As DropDown
With ActiveSheet
Set drpdwn = .DropDowns(Application.Caller)
Select Case drpdwn.ListIndex
Case "All"
' no selection, do nothing
Case 1
' Item1 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 127), ..Cells(4, 127))
Case 2
' item2 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 128), ..Cells(4, 128))
Case 3
' item3 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 129), ..Cells(4, 129))
Case 4
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 130), ..Cells(4, 130))
Case 5 To 14
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 131), ..Cells(4, 131))
End Select


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default ComboBox processing error

I'm not quite sure what you're doing.

But I placed two comboboxes from the control toolbox toolbar (not the Forms
toolbar) on to a worksheet and used this code:

Option Explicit
Dim blkProc As Boolean
Private Sub ComboBox1_Change()

'just for testing!
'MsgBox Me.ComboBox1.ListIndex

blkProc = True
Me.ComboBox2.Value = ""
blkProc = False

With Me
Select Case Me.ComboBox1.ListIndex
Case 0
Me.ComboBox2.ListFillRange _
= .Range(.Cells(3, 127), .Cells(4, 127)) _
.Address(external:=True)
Case 1
Me.ComboBox2.ListFillRange _
= .Range(.Cells(3, 128), .Cells(4, 128)) _
.Address(external:=True)
Case 2
Me.ComboBox2.ListFillRange _
= .Range(.Cells(3, 129), .Cells(4, 129)) _
.Address(external:=True)
Case 3
Me.ComboBox2.ListFillRange _
= .Range(.Cells(3, 130), .Cells(4, 130)) _
.Address(external:=True)
Case 4 To 13
ComboBox2.ListFillRange _
= .Range(.Cells(3, 131), .Cells(4, 131)) _
.Address(external:=True)
End Select
End With
End Sub
Private Sub ComboBox2_Change()
If blkProc Then Exit Sub
MsgBox "you changed it to: " & Me.ComboBox2.Value
End Sub

When the first item is selected, it's .listindex = 0.

And I wasn't sure if you had any code for when the 2nd combobox changed--but if
it's changed in code, you may want to block that code from running (that's what
the BlkProc variable does).

The .listfillrange is looking for a string. The .address(external:=true) did
that.

If you used the dropdowns from the Forms toolbar, the idea will be similar--but
it will be implemented differently.

And one more thing...

These newsgroups are pretty much plain text--no HTML postings and no
attachments. Can you please post in plain text. It'll make it easier for some
of us older people to read your posts.

(and you may find you get more responses!)


Jim Berglund wrote:

Thanks, I tried your suggestions, but didn't get the results I wanted. I've
used forms in the past, but was trying something different. However, I did
come up with a visual, but less elegant approach, using if statements that
does give me the cascading effect I was looking for. (Shown below...)

Private Sub ComboBox4_Change() 'Supertype
Dim sX As Variant
Application.ScreenUpdating = False

With ActiveSheet
.Range("DP5:DP200").Clear
sX = .Range("CB3").Text
i = 5

If sX = Range("CX20").Value Then
Else
If sX = Range("CY20").Text Then
While .Cells((i + 16), 103).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 103).Value
i = i + 1
Wend
Else
If sX = Range("CZ20").Text Then
While .Cells((i + 16), 104).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 104).Value
i = i + 1
Wend
Else
If sX = Range("DA20").Text Then
While .Cells((i + 16), 105).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 105).Value
i = i + 1
Wend
Else
If sX = Range("DB20").Text Then
While .Cells((i + 16), 106).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 106).Value
i = i + 1
Wend
Else
If sX = Range("DC20").Text Then
While .Cells((i + 16), 107).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 107).Value
i = i + 1
Wend
Else
If sX = Range("DD20").Text Then
While .Cells((i + 16), 108).Text < ""
.Cells(i, 120).Value = .Cells((i + 16), 108).Value
i = i + 1
Wend
End If

End If
End If
End If
End If
End If
End If
End With

End Sub
It creates a list which will be used as the ListFillRange for the
second combobox. I'd appreciate more detailed suggestions for a simpler
approach, if you feel this is just too ungainly.

FYI, This is a massive data management project that I'm (independently)
working on to handle equipment replacement decisions for large fleets based on
fleet asset and maintenance history. The data is collected and massaged
using Cognos, but the detailed operations are done in Excel.

Regards,
Jim Berglund

"Dave Peterson" wrote in message
...
It also looks like the combobox was created from the control toolbox

toolbar.

If you replace that combobox with a dropdown from the Forms toolbar and move
your code into a general module, does it work?

Also, the .listindex will always be a number--never "All".



Jim Berglund wrote:

Can someone please help me with the following? I want the contents of a
'Regions' ComboBox to subset the possible choices in a second Combobox. I

get
a 1004 error relating to the DropDown variable...

Thanks,
Jim Berglund
__________________________________________________ _______________________
Private Sub ComboBox1_Change()
Dim drpdwn As DropDown
With ActiveSheet
Set drpdwn = .DropDowns(Application.Caller)
Select Case drpdwn.ListIndex
Case "All"
' no selection, do nothing
Case 1
' Item1 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 127), .Cells(4, 127))
Case 2
' item2 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 128), .Cells(4, 128))
Case 3
' item3 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 129), .Cells(4,

129))
Case 4
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 130), .Cells(4,

130))
Case 5 To 14
' one of item 4 to 14 selected
ComboBox2.ListFillRange = .Range(.Cells(3, 131), .Cells(4,

131))
End Select


--

Dave Peterson


--

Dave Peterson


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
Automatic error processing? Sutemi Excel Discussion (Misc queries) 1 October 4th 05 02:05 PM
Error processing the dimension '[Microsoft][ODBC dBase Driver] To. Catalin Excel Discussion (Misc queries) 0 April 22nd 05 05:48 PM
Combobox creates error Stephen Excel Worksheet Functions 0 January 23rd 05 10:55 AM
error (ComboBox-?) Alex Excel Programming 2 June 18th 04 02:52 AM
Combobox run time error Oreg[_18_] Excel Programming 1 June 7th 04 04:46 AM


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