Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default listbox change with combobox selection

I am trying to get a listbox to update based on a combobox selection.
Unfortunately my combobox options are W4,W5,W6 etc. which I cannot use
to name ranges in excel. Otherwise I would have used the following
code:

Private Sub ComboBoxgroupW_Change()

UserFormDesign.ListBoxW.RowSource = UserFormDesign.ComboBoxgroupW.Value

End Sub

that way each time the combobox was changed, the list would be updated
with the range that corresponded to the selection. If there is a way
around that, without renaming the combobox choices, that would be
great. here is my second option which is not working at all:

Private Sub ComboBoxgroupW_Change()

I = UserFormDesign.ComboBoxgroupW.Value

Select Case I
Case W4
UserFormDesign.ListBoxW.RowSource = WIDE4
Case W5
UserFormDesign.ListBoxW.RowSource = WIDE5
Case W6
UserFormDesign.ListBoxW.RowSource = WIDE6
Case W8
UserFormDesign.ListBoxW.RowSource = WIDE8
Case W10
UserFormDesign.ListBoxW.RowSource = WIDE10
Case W12
UserFormDesign.ListBoxW.RowSource = WIDE12
Case W14
UserFormDesign.ListBoxW.RowSource = WIDE14
Case W16
UserFormDesign.ListBoxW.RowSource = WIDE16
Case W18
UserFormDesign.ListBoxW.RowSource = WIDE18
Case W21
UserFormDesign.ListBoxW.RowSource = WIDE21
Case W24
UserFormDesign.ListBoxW.RowSource = WIDE24
Case W27
UserFormDesign.ListBoxW.RowSource = WIDE27
Case W30
UserFormDesign.ListBoxW.RowSource = WIDE30
Case W33
UserFormDesign.ListBoxW.RowSource = WIDE33
Case W36
UserFormDesign.ListBoxW.RowSource = WIDE36
Case W40
UserFormDesign.ListBoxW.RowSource = WIDE40
Case W44
UserFormDesign.ListBoxW.RowSource = WIDE44
Case ALL
UserFormDesign.ListBoxW.RowSource = ALLW
End Select
End Sub


WIDE4, WIDE5, WIDE6, etc. are the named ranges that I want to show in
the listbox. Nothing happens when I run this code. what am I doing
wrong?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default listbox change with combobox selection

How about

Private Sub ComboBoxgroupW_Change()

With UserFormDesign
.ListBoxW.RowSource = range(.ComboBoxgroupW.Value).address
End With

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
ups.com...
I am trying to get a listbox to update based on a combobox selection.
Unfortunately my combobox options are W4,W5,W6 etc. which I cannot use
to name ranges in excel. Otherwise I would have used the following
code:

Private Sub ComboBoxgroupW_Change()

UserFormDesign.ListBoxW.RowSource = UserFormDesign.ComboBoxgroupW.Value

End Sub

that way each time the combobox was changed, the list would be updated
with the range that corresponded to the selection. If there is a way
around that, without renaming the combobox choices, that would be
great. here is my second option which is not working at all:

Private Sub ComboBoxgroupW_Change()

I = UserFormDesign.ComboBoxgroupW.Value

Select Case I
Case W4
UserFormDesign.ListBoxW.RowSource = WIDE4
Case W5
UserFormDesign.ListBoxW.RowSource = WIDE5
Case W6
UserFormDesign.ListBoxW.RowSource = WIDE6
Case W8
UserFormDesign.ListBoxW.RowSource = WIDE8
Case W10
UserFormDesign.ListBoxW.RowSource = WIDE10
Case W12
UserFormDesign.ListBoxW.RowSource = WIDE12
Case W14
UserFormDesign.ListBoxW.RowSource = WIDE14
Case W16
UserFormDesign.ListBoxW.RowSource = WIDE16
Case W18
UserFormDesign.ListBoxW.RowSource = WIDE18
Case W21
UserFormDesign.ListBoxW.RowSource = WIDE21
Case W24
UserFormDesign.ListBoxW.RowSource = WIDE24
Case W27
UserFormDesign.ListBoxW.RowSource = WIDE27
Case W30
UserFormDesign.ListBoxW.RowSource = WIDE30
Case W33
UserFormDesign.ListBoxW.RowSource = WIDE33
Case W36
UserFormDesign.ListBoxW.RowSource = WIDE36
Case W40
UserFormDesign.ListBoxW.RowSource = WIDE40
Case W44
UserFormDesign.ListBoxW.RowSource = WIDE44
Case ALL
UserFormDesign.ListBoxW.RowSource = ALLW
End Select
End Sub


WIDE4, WIDE5, WIDE6, etc. are the named ranges that I want to show in
the listbox. Nothing happens when I run this code. what am I doing
wrong?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default listbox change with combobox selection

that does the same thing as my first code which does not work. that is
assigning W4,W5,W6 etc. to the RowSource of the listbox which is not
correct since excel would not let me name the ranges W4, W5, W6 etc. I
need to get the RowSource of the list box to WIDE4, WIDE5, etc.
without changing the combobox list. thanks for your help though.


Bob Phillips wrote:
How about

Private Sub ComboBoxgroupW_Change()

With UserFormDesign
.ListBoxW.RowSource = range(.ComboBoxgroupW.Value).address
End With

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Jacob" wrote in message
ups.com...
I am trying to get a listbox to update based on a combobox selection.
Unfortunately my combobox options are W4,W5,W6 etc. which I cannot use
to name ranges in excel. Otherwise I would have used the following
code:

Private Sub ComboBoxgroupW_Change()

UserFormDesign.ListBoxW.RowSource = UserFormDesign.ComboBoxgroupW.Value

End Sub

that way each time the combobox was changed, the list would be updated
with the range that corresponded to the selection. If there is a way
around that, without renaming the combobox choices, that would be
great. here is my second option which is not working at all:

Private Sub ComboBoxgroupW_Change()

I = UserFormDesign.ComboBoxgroupW.Value

Select Case I
Case W4
UserFormDesign.ListBoxW.RowSource = WIDE4
Case W5
UserFormDesign.ListBoxW.RowSource = WIDE5
Case W6
UserFormDesign.ListBoxW.RowSource = WIDE6
Case W8
UserFormDesign.ListBoxW.RowSource = WIDE8
Case W10
UserFormDesign.ListBoxW.RowSource = WIDE10
Case W12
UserFormDesign.ListBoxW.RowSource = WIDE12
Case W14
UserFormDesign.ListBoxW.RowSource = WIDE14
Case W16
UserFormDesign.ListBoxW.RowSource = WIDE16
Case W18
UserFormDesign.ListBoxW.RowSource = WIDE18
Case W21
UserFormDesign.ListBoxW.RowSource = WIDE21
Case W24
UserFormDesign.ListBoxW.RowSource = WIDE24
Case W27
UserFormDesign.ListBoxW.RowSource = WIDE27
Case W30
UserFormDesign.ListBoxW.RowSource = WIDE30
Case W33
UserFormDesign.ListBoxW.RowSource = WIDE33
Case W36
UserFormDesign.ListBoxW.RowSource = WIDE36
Case W40
UserFormDesign.ListBoxW.RowSource = WIDE40
Case W44
UserFormDesign.ListBoxW.RowSource = WIDE44
Case ALL
UserFormDesign.ListBoxW.RowSource = ALLW
End Select
End Sub


WIDE4, WIDE5, WIDE6, etc. are the named ranges that I want to show in
the listbox. Nothing happens when I run this code. what am I doing
wrong?


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
Chart content to change according to a selection on a combobox Johanna Gronlund Charts and Charting in Excel 1 February 2nd 10 02:05 PM
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Combobox items determined by the selection in another combobox Alerion Excel Programming 2 September 13th 06 01:07 PM
Listbox Event for selection/scroll change Riddler Excel Programming 2 August 25th 06 07:01 PM
Combobox v Listbox MBlake New Users to Excel 5 April 24th 05 11:58 AM


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