Error Placing A Default Value In A Userform Combobox

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to use the code below to place a single default value into a userform combobox. But I am getting error : "Could not set the value property. Invalid property value." with the line in red. Any help to get past this error will be greatly appreciated.

When the user select a value from combox "league" on the userform a selection of KWMLA executes this (portion of) code.

Rich (BB code):
Case Is = "KWMLA"
        Stop
            Set nr_calibre = ws_lists.Range("G2:G2") 'range G2:G2 = "REP"
            Set nr_dvsion = ws_lists.Range("H33:H38")
            t = 2
            bigandbad t '{frm_chg_3League}
            permit.cbx_calibre.Value = "REP"

VBA Code:
Sub bigandbad(ByRef t As Double)
                
        Dim mycell As Range
        If t = 1 Then
            'user selects from both calibre and division lists
            'prepare calibre
            If nr_calibre.Count = 1 Then
                permit.cbx_calibre.List = Array(nr_calibre.Value)
            Else
                permit.cbx_calibre.List = nr_calibre.Value
            End If
            permit.cbx_calibre.Enabled = True
            permit.cbx_calibre.BackColor = clr_blue
            'prepare division
            If nr_calibre.Count = 1 Then
                permit.cbx_division.List = Array(nr_division.Value)
            Else
                permit.cbx_division.List = nr_dvsion.Value
            End If
            permit.cbx_division.Enabled = False
            
            chk_main '{frm_permit}*
            customer '{frm_activity_reference}*
                    
        ElseIf t = 3 Then
            'prepare calibre
            If nr_calibre.Count = 1 Then
                permit.cbx_calibre.List = Array(nr_calibre.Value)
            Else
                permit.cbx_calibre.List = nr_calibre.Value
            End If
            permit.cbx_calibre.Enabled = False
            'prepare division
            If nr_dvsion.Count = 1 Then
                permit.cbx_division.List = Array(nr_dvsion.Value)
            Else
                permit.cbx_division.List = Range("nr_dvsion").Value
            End If
            permit.cbx_division.Enabled = False
            
            chk_main '{frm_permit}*
            customer '{frm_activity_reference}*
            
        ElseIf t = 2 Then
            'Stop
            'calibre defined, division selectable

            'prepare calibre
            If nr_calibre.Count = 1 Then
                permit.cbx_calibre.List = Array(Range("nr_calibre").Value)
            Else
                permit.cbx_calibre.List = Range("nr_calibre").Value
            End If
            permit.cbx_calibre.Enabled = True
            permit.cbx_calibre.BackColor = clr_blue
            'prepare division
            If nr_dvsion.Count = 1 Then
                permit.cbx_division.List = Array(Range("nr_division").Value)
            Else
                permit.cbx_division.List = nr_dvsion.Value
            End If
            permit.cbx_division.Enabled = True
            'permit.cbx_division.BackColor = clr_blue
            
            chk_main '{frm_permit}*
            customer '{frm_activity_reference}*
        
        Else 't=4
            'variable division based on calibre selection (minor groups with HL & REP)
            If nr_calibre.Count = 1 Then
                permit.cbx_calibre.List = Array(nr_calibre.Value)
            Else
                permit.cbx_calibre.List = nr_calibre.Value
            End If
            permit.cbx_calibre.Enabled = True
            permit.cbx_calibre.BackColor = clr_blue
            permit.cbx_division.BackColor = vbWhite
            permit.cbx_division.Enabled = False
            
            chk_main '{frm_permit}*
            customer '{frm_activity_reference}*

        End If
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
It looks like you have the MatchRequired property of the Combo Box set to true.
A line of code like
VBA Code:
permit.cbx_calibre.MatchRequired = False
might solve your issue.
 
Upvote 0
Hi GWteB! Thanks for the suggestion, but unless I put it in the wrong place, it didn't solve the problem. :-(
 
Upvote 0
Obviously before the line with
Code:
permit.cbx_calibre.Value = "REP"
 
Upvote 0
LOL ... that was my first guess and that's where it went.
Code:
Case Is = "KWMLA"
        Stop
            Set nr_calibre = ws_lists.Range("G2:G2") 'rep
            Set nr_dvsion = ws_lists.Range("H33:H38")
            t = 2
            bigandbad t '{frm_chg_3League}
            permit.cbx_calibre.MatchRequired = False
            permit.cbx_calibre.Value = "REP"
 
Upvote 0
If that was to no avail I don't have any other alternative, I'm afraid. Perhaps another member has a suggestion of something I'm overlooking.
 
Upvote 0
Pitty your issue isn't resolved yet.
 
Upvote 0
I actually just figured it out. I forgot that I had already asked this same question once already withthis project (some people just can't learn).

Rich (BB code):
            If nr_calibre.Count = 1 Then
                permit.cbx_calibre.List = Array(nr_calibre.Value)
            Else
                permit.cbx_calibre.List = nr_calibre.Value
            End If

Removing the range reference and the quotation marks seems to have done the trick.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
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