Reputation: 3
I have a userform with 3 comboboxes and a command button that, when clicked, puts the entered values into a sheet. I have MatchRequired set to True for all 3 so that other values can't be entered in.
My problem is that I can get past each combobox with no problems as there aren't any inaccuracies. However when I click the command button the Invalid Property Value error comes up. Also - the entry still gets added to the sheet, even with the error. What gives?
I'm loading the combobox options from different columns on that same sheet. Here's the code I have for the command button:
Private Sub cmdAddClass_Click()
Dim RowCount As Long
RowCount = Worksheets("Sheet2").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet2").Range("A1")
.Offset(RowCount, 0).Value = Me.cboGrade.Value
.Offset(RowCount, 1).Value = Me.cboUnits.Value
.Offset(RowCount, 2).Value = Me.cboQuarter.Value
End With
Me.cboGrade.Value = ""
Me.cboUnits.Value = ""
Me.cboQuarter.Value = ""
Me.cboGrade.SetFocus
End Sub
New here, so thank you for any and all help.
Upvotes: 0
Views: 709
Reputation: 53126
You issue is:
Me.cboGrade.Value = ""
'...
Me.cboGrade.SetFocus
You are setting cboGrade
to blank, which is not a value in the combobox list. Therefore when you set the focus to cboGrade
, the MatchRequired
setting rejects it and issues the Invalid Property Value
message. Note that this is not actually a VBA error, it's a message from the form control.
Try removing Me.cboGrade.SetFocus
Upvotes: 1