Help w/creating cascading listboxes

RunTime91

Active Member
Joined
Aug 30, 2012
Messages
290
Office Version
  1. 365
On my personal laptop in a test workbook I have the following code which sets the RowSource for ListBox4 based on the selection/Value of ListBox2 - And it works perfectly.
Code:
If ListBox2.Value = "Boo" Then
  Me.ListBox4.RowSource = "Sheet4!B2:B9"
ElseIf Me.ListBox2.Value = 2 Then
  Me.ListBox4.RowSource = "Sheet4!C2:C9"
End if

On another laptop I have the following code which I am essentially asking to do the same thing but in a more complex code environment.
The following code works perfectly excluding the " If Me.LstOutcomes.Value = "Left Message"" The selection in LstOutcomes is indeed "Left Message"
However, the line If Me.LstOutcomes.Value = "Left Message" returns a Null error.
If I skip this line the RowSource for ListBox: LstLMNotes is set perfectly...

Not seein' what I'm missin'

Code:
If Opt1n1 = True Then
  GoTo Foo
End if

Foo:

Set Ws1 = ThisWorkbook.Sheets("LM Notes")
Lr1 = Ws1.Cells(Rows.Count, 1).End(xlUp)
Set Rng1 = Ws1.Range("A2:B" & Lr1)

If Me.LstOutcomes.Value = "Left Message" Then
  Me.LstLMNotes.RowSource = Rng1.Address(External:= True)
End if

End Sub

Thank You, All as always for any assistance

RT 91
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Did you hide a column in the 2nd listbox? The "chosen" and displayed value is not necessarily the value of the listbox.; at least it won't be if you hid any columns to the left. Put a break point on the If line and run the code. When it stops there, type ?Me.LstOutcomes in the immediate window and hit enter. The value of the reference will be shown below the line you typed. If you get a carriage return (no visible output) then the value is an empty string and not what you're expecting.

The 1st 3 lines of that code make no sense. What comes after Foo: will execute regardless of that If block.
 
Upvote 0
Solution
Ugh, yeah, regarding the code not making sense, I posted just a snippet of the whole code block and should have added an Exit Sub to make the snippet make sense.

As for your solution... jsmh

I did check the properties of the listboxes used between to two code blocks
And, Yeah... I completely missed that I was not referencing the 'bound column'

Problem Solved...

Thank You, Micron ~
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,103
Messages
6,170,123
Members
452,303
Latest member
c4cstore

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top