ComboBox Only Recognizes Text Items When Selecting a Value To Populate ListBox

RunTime91

Active Member
Joined
Aug 30, 2012
Messages
290
Office Version
  1. 365
Greetings All...

Setup:

I am providing the enduser (eu) a list of items in a ComboBox on a UserForm. When the eu selects an item from the ComboBox, a ListBox will populate with another list from which the eu can make a selection to open word/pdf docs providing the eu with written instructions about the topic selected in the ListBox.

Everything works great until the eu selects one of the items in the ComboBox list that is a number instead of text. When this happens the code brings back nothing.
I've tested this and if I change 435 to 435C the ListBox will populate with the links to the documents regarding the 435. If I remove the 'C' the code once again brings back nothing.

I have tried to change the format of the list that populates the ComboBox at the sheet level using the Format Cells window - No change.

So I'm assuming I have to fix this at the code level. Is there an easy fix to this?

Not sure what code I can provide to help you, help me...

But please let me know as, I definitely need help

Sincerely,

RT91
 
Error in explicit conversion procedure.
Should be:
VBA Code:
Private Sub CmbSortTest_Change()
    Dim v As Variant
    Dim vCmbVal As Variant
    Dim k As Long
    Dim i As Long
    Dim vLst As Variant

    v = Worksheets("I&I").Range("D2:E54").Value

    vCmbVal = Me.CmbSortTest.Value
    If IsNumeric(vCmbVal) Then
        vCmbVal = CDbl(vCmbVal)
    End If

    ReDim vLst(1 To UBound(v))

    Me.LstHowToDocs.Clear

    For i = 2 To UBound(v)
        If vCmbVal = v(i, 1) Then
            k = k + 1
            vLst(k) = v(i, 2)
        End If
    Next i

    If k > 0 Then
        ReDim Preserve vLst(1 To k)
        Me.LstHowToDocs.Column = vLst
    End If
End Sub

Artik
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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