Listbox returning NOTHING despite it being populated

nigelandrewfoster

Well-known Member
Joined
May 27, 2009
Messages
747
Hi,

The following code stores the values in a userform, containing several list boxes and text boxes:
Code:
Sub Write_Item()    Dim ItemRow As Integer, r As Range, Typ
    Typ = Array("Ambient", "Fresh", "Kit", "Literature", "Non-Consumables")
    With IngredientRecord_Form
        ItemRow = ItemRowOs(.ItemName_Txt.Value)
        If ItemRow >= 1 Then
            Set r = Worksheets("Items").[a1].Offset(ItemRow)
        Else
            Set r = Worksheets("Items").[b2]
            Do While r <> ""
                Set r = r.Offset(1)
            Loop
            Set r = r.Offset(, -1)
        End If
        r.Value = .ItemType_List.Value
        r.Offset(, 1).Value = .ItemName_Txt.Value
        r.Offset(, 2).Value = .ItemCode_Txt.Value
        r.Offset(, 3).Value = .AMPM_List.Value
        r.Offset(, 4).Value = .Supplier_List.Value
[SIZE=2][I][B]        r.Offset(, 5).Value = .Ranging_List.Value[/B][/I][/SIZE]
        r.Offset(, 6).Value = .Incost_Txt.Value
        r.Offset(, 7).Value = .UnitCase_Txt.Value
        r.Offset(, 8).Value = .SampleUnit_Txt.Value
        r.Offset(, 9).Value = .SampleCase_Txt.Value
        r.Offset(, 10).Value = .SampleType_Txt.Value
        r.Offset(, 11).Value = .ProdCode_Txt.Value
        r.Offset(, 13).Value = .TimeDist_Txt.Value
        .ItemName_Txt.SetFocus
    End With
End Sub

The row source for .Ranging_List is a three cell column, containing "All", "Prog" and "Trad". The default highlighted value is "All". When I run the macro, .Ranging_List.Value returns "".
Its ListIndex is 0, so it should return "All". The two neighbouring list boxes are returning their default (and highlighted) values, so why not this one? Any ideas? Very puzzling.

Thanks for reading.

Nigel
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
have you tried using this instead?

Code:
[SIZE=2][I][B]        r.Offset(, 5).[SIZE=2][I][B]Text[/B][/I][/SIZE] = .Ranging_List.[SIZE=2][I][B][SIZE=2][/SIZE]Value[/B][/I][/SIZE][/B][/I][/SIZE]
 
Last edited:
Upvote 0
I will give it a try. It appears to be random which work and which don't which suggests some subtlety in the Listbox method which has eluded me.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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