Error Setting A userform Combobox List to a Named Range

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to assign a userform combobox a list based on a predefined named range of cells with the code below. The line in red is giving me an error: "Could not set the list property. Invalid property array index."

Rich (BB code):
Sub ref_activity()

    Dim chng As Double, cnt As Double
    Dim df_other1 As String
    Dim nm_shut As Range, nm_gen As Range, nm_pas As Range, nm_lcs As Range, nm_hyd As Range, nm_wtr As Range, nm_ph As Range ', nm_exp135 As Range, nm_exp136 As Range
    Dim r As Integer, prow As Integer

    'define default names for activity fields
    
    ActiveWorkbook.Names.Add Name:="nm_shut", RefersTo:=ws_lists.Range("M2:M4")
    ActiveWorkbook.Names.Add Name:="nm_gen", RefersTo:=ws_lists.Range("Y2:Y4")
    ActiveWorkbook.Names.Add Name:="nm_pas", RefersTo:=ws_lists.Range("N2:N4")
    ActiveWorkbook.Names.Add Name:="nm_lcs", RefersTo:=ws_lists.Range("N2:N4")
    ActiveWorkbook.Names.Add Name:="nm_hyd", RefersTo:=ws_lists.Range("O2:O4")
    ActiveWorkbook.Names.Add Name:="nm_wtr", RefersTo:=ws_lists.Range("O2:O4")
    ActiveWorkbook.Names.Add Name:="nn_ph", RefersTo:=ws_lists.Range("O2:O4")

    If permitexists = True Then 'rental exists, populate data
        Stop
        'prmt_exists
        'MsgBox "Are buttons accessible and operable?"
    
    Else                        'permit doesn't exist
        'Stop
        str_activity = permit.cbx_func.Value & permit.cbx_league.Value & permit.cbx_calibre.Value & permit.cbx_division.Value
        cnt = Application.WorksheetFunction.CountIf(ws_ad.Columns(5), str_activity)
        If cnt = 1 Then         'activity detail exists
            ade = True
            r9 = Application.WorksheetFunction.Match(str_activity, ws_ad.Columns(5), 0)
            df_actdet_avail
        Else                    'no activity detail on file
            ade = False
            If rcode Like "D*" Then
                df_actdet_navail_dia
            ElseIf rcode Like "F*" Then
                df_actdet_navail_fld
            End If
        End If
    End If
    
    'populate setup fields
    With permit

        ElseIf rcode = "GS" Then
            .tb_f4_att.Value = df_attend
            .tb_f4_att.Enabled = True
            chk_main
            With .cbx_f4_shut
                .Value = df_shut
                .List = Range("nm_shut")
                .Enabled = True
                chk_main
            End With
            With .cbx_f4_gen
                .Value = df_gen
                .List = Range("nm_gen")
                .Enabled = True
                chk_main
            End With
            With .cbx_f4_pas
                .Value = df_pas
                .List = Range("nm_pas")
                .Enabled = True
                chk_main
            End With
            With .cbx_f4_license
                .Value = df_lcs
                .List = Range("nm_lcs")
                .Enabled = True
                chk_main
            End With
            
            tb_f4_tables.Value = df_tblh
            tb_f4_tables.Enabled = True
            chk_main

            With .cbx_f4_hydro
                .Value = df_hyd
                .List = Range("nm_hyd")
                .Enabled = True
                chk_main
            End With
            With .cbx_f4_water
                .Value = df_wtr
                .List = Range("nm_wtr")
                .Enabled = True
                chk_main
            End With
            With .cbx_f4_ph
                .Value = df_ph
                .List = Range("nm_ph")
                .Enabled = True
                chk_main
            End With
            .tb_f4_fence.Value = df_pf
            chk_main
            'tb_ft_other = df_o1
        Else
            MsgBox "Error: Populate"
        End If
    End With
    
End Sub

Is anyone able to help me correct this error? I apologize if this is the same problem, or similar to the one I posted here. I feel it's similar, but not quite sure how and I haven't quite figured out how it all relates.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try
VBA Code:
.List = Range("nm_shut").Value
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
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