Error Handler won't trigger if Runtime Error is 380 (Could not set RowSource property)

Sabotage

Board Regular
Joined
Sep 19, 2013
Messages
58
Hi Wizzards!
I have a problem not being able to trigger my error handler after the code is trying to set an "empty list" for combobox rowsource. In a nutshell my code is trying to set the rowsource for a combobox, depending on a value in another combobox's value. I have tried to put "On Error GoTo Err1" where Err1 is my Error Handler. Tried to put it before Select Case and inside Select Case but no luck what so ever. My Error Handler would just tell the user that the specified supplier does not have any store location set and exit the procedure. The user hence will know what is wrong...

Thank you in advance!

Code:
        Select Case cb_Supplier
            Case "Supplier ABC"
                On Error GoTo Err1
                cb_StoreName.RowSource = "SupLoc_ABC"   'error occurs
                On Error GoTo 0
            Case "Supplier XYZ"
                On Error GoTo Err1
                cb_StoreName.RowSource = "SupLoc_XYZ"   'error occurs
                On Error GoTo 0

        End Select
 
Can you supply the complete code for that procedure?
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
[MENTION][/MENTION]
Can you supply the complete code for that procedure?

Code:
Private Sub cb_Supplier_Change()
    Dim DT, LI, CP As Worksheet
    Set DT = Worksheets("DataTable")
    Set LI = Worksheets("DB_LoadID")
    Set CP = Worksheets("CPanel")
    Dim xRng As Range
    Dim nRng, LastID As String
    Dim lRow, myCol As Long
    Application.ScreenUpdating = False
        With DT
            .Range("XFC1").Value = cb_Supplier.Value
            lbl_PrefixLiD.Caption = .Range("XFD1").Value
        End With
        nRng = DT.Range("XFD3").Value
        With LI
            .Range("XFD:XFD").ClearContents
            On Error GoTo Err2
                Range(nRng).Copy
            .Range("XFD1").PasteSpecial (xlPasteValues)
            Application.CutCopyMode = False
            lRow = .Range("XFD" & Rows.Count).End(xlUp).Row
            LastID = .Range("XFD" & lRow).Value
        End With
            lbl_LastLiD.Caption = LastID
            tb_LoadID.Value = lbl_PrefixLiD.Caption & "-"
StoreNam:
       Select Case cb_Supplier
            Case "Brook Valley Salvage Inc"
                cb_StoreName.RowSource = "SupLoc_BVSI"
            Case "Cycla LLC"
                cb_StoreName.RowSource = "SupLoc_CYCL"
            Case "EcoGoodz LLC"
                cb_StoreName.RowSource = "SupLoc_ECGZ"
            Case "Goodwill Greater Washington"
                cb_StoreName.RowSource = "SupLoc_GWGW"
            Case "Goodwill Industries Chatt Inc"
                cb_StoreName.RowSource = "SupLoc_GWCT"
            Case "Goodwill Industries of Greater NY & N. New Jersey Inc"
                cb_StoreName.RowSource = "SupLoc_GWNN"
            Case "Goodwill Industries of Kentucky"
                cb_StoreName.RowSource = "SupLoc_GWKY"
            Case "Goodwill Industries of North Georgia"
                cb_StoreName.RowSource = "SupLoc_GWNG"
            Case "Goodwill Southeast Georgia"
                cb_StoreName.RowSource = "SupLoc_GWSG"
            Case "J & T Management"
                cb_StoreName.RowSource = "SupLoc_JnTM"
            Case "Missouri Recycling Company"
                cb_StoreName.RowSource = "SupLoc_MORC"
            Case "Omega Recycling Inc"
                cb_StoreName.RowSource = "SupLoc_OMRI"
            Case "Rappahannock Goodwill Industries Inc"
                cb_StoreName.RowSource = "SupLoc_GWRP"
            Case "Savers Recycling Inc"
                cb_StoreName.RowSource = "SupLoc_SAVR"
            Case "St. Vincent de Paul Society"
                cb_StoreName.RowSource = "SupLoc_STVP"
            Case "The Salvation Army"
                cb_StoreName.RowSource = "SupLoc_SALV"
            Case "ThredUP Inc"
                cb_StoreName.RowSource = "SupLoc_THUP"
            Case "Value Village Stores"
                cb_StoreName.RowSource = "SupLoc_VVLS"
        End Select
    Application.ScreenUpdating = True
    Exit Sub
Err1:
    'if there is no store for the specified supplier!
        MsgBox "This specified Supplier doesn't have any Store Location set!" & vbNewLine & vbNewLine & _
            "Please set up all Store names before trying to register a new load!", vbInformation, "Error..."
            Application.ScreenUpdating = True
            On Error GoTo 0
            Exit Sub
Err2:
    'if no Load-ID exist for this supplier yet!
        MsgBox "This supplier hasn't had any unique Load-ID yet!" & vbNewLine & _
            "Please use the given Load-ID prefix and the number (1001) to create the first unique Load-ID!", vbInformation, "Note..."
            tb_LoadID.Value = lbl_PrefixLiD.Caption & "-"
            On Error GoTo 0
            GoTo StoreNam
End Sub
 
Upvote 0
All lines in Select Case could be removed with a simple 2 column lookup in a (hidden?) sheet

This one line replaces all of them
Code:
cb_StoreName.RowSource =  WorksheetFunction.VLookup(cb_Supplier, Range("MyTable"), 2, 0)

The lookup range looks like this (I named the range "MyTable" )
[TABLE="width: 523"]
<tbody>[TR]
[TD]Brook Valley Salvage Inc
[/TD]
[TD] SupLoc_BVSI[/TD]
[/TR]
[TR]
[TD]Cycla LLC[/TD]
[TD] SupLoc_CYCL[/TD]
[/TR]
[TR]
[TD]EcoGoodz LLC[/TD]
[TD] SupLoc_ECGZ[/TD]
[/TR]
[TR]
[TD]Goodwill Greater Washington[/TD]
[TD] SupLoc_GWGW[/TD]
[/TR]
[TR]
[TD]Goodwill Industries Chatt Inc[/TD]
[TD] SupLoc_GWCT[/TD]
[/TR]
[TR]
[TD]Goodwill Industries of Greater NY & N. New Jersey Inc[/TD]
[TD] SupLoc_GWNN[/TD]
[/TR]
[TR]
[TD]Goodwill Industries of Kentucky[/TD]
[TD] SupLoc_GWKY[/TD]
[/TR]
[TR]
[TD]Goodwill Industries of North Georgia[/TD]
[TD] SupLoc_GWNG[/TD]
[/TR]
[TR]
[TD]Goodwill Southeast Georgia[/TD]
[TD]SupLoc_GWSG[/TD]
[/TR]
[TR]
[TD]J & T Management[/TD]
[TD] SupLoc_JnTM[/TD]
[/TR]
[TR]
[TD]Missouri Recycling Company[/TD]
[TD] SupLoc_MORC[/TD]
[/TR]
[TR]
[TD]Omega Recycling Inc[/TD]
[TD] SupLoc_OMRI[/TD]
[/TR]
[TR]
[TD]Rappahannock Goodwill Industries Inc[/TD]
[TD] SupLoc_GWRP[/TD]
[/TR]
[TR]
[TD]Savers Recycling Inc[/TD]
[TD] SupLoc_SAVR[/TD]
[/TR]
[TR]
[TD]St. Vincent de Paul Society[/TD]
[TD] SupLoc_STVP[/TD]
[/TR]
[TR]
[TD]The Salvation Army[/TD]
[TD] SupLoc_SALV[/TD]
[/TR]
[TR]
[TD]ThredUP Inc[/TD]
[TD] SupLoc_THUP[/TD]
[/TR]
[TR]
[TD]Value Village Stores[/TD]
[TD] SupLoc_VVLS[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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