Error With Assigning A Named Range To A Userform Combobox List

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Rich (BB code):
Sub ref_activity()
'Stop
    Dim chng As Double, cnt As Double
    Dim df_o1 As String
    Dim nm_fldconfig As Range, nm_gs As Range
    Dim r As Integer, prow As Integer
    'mbevents = False
'Stop

    'define default names for activity fields
   
    ActiveWorkbook.Names.Add Name:="nm_fldconfig", RefersTo:=ws_lists.Range("U2:U19")
    ActiveWorkbook.Names.Add Name:="nm_gs", RefersTo:=ws_lists.Range("V2:V15")
   
    'populate setup fields
    With permit
        If rcode Like "D*" Then
            ....
        ElseIf rcode Like "F*" Then
            With .cbx_f2_fc
                .List = nm_fldconfig.Value
                .Value = df_fldconfig
                chk_main
            End With
            With .cbx_f2_gl
                .List = Range("nm_gs")
                Value = df_gs
                chk_main
            End With
            .tb_f2_other.Text = df_o1
        End If
    End With
   
End Sub

The line in purple declares variable nm_fldconfig as a range
The line in green creates the named range.
Permit is the userform, cbx_f2_fc is the combox on that form.
The line in red is leaving me with an error ... "Object variable or With block variable not set."

Any thoughts on how I can correct this?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You have not assigned a range to the nm_fldconfig variable, hence the error.
If you want to use a named range use
VBA Code:
[B].[/B]List = Range("nm_fldconfig").Value
or if you want to use a range variable use
VBA Code:
Set nm_fldconfig = ws_lists.Range("U2:U19")
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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