Userform code problem

Adz

New Member
Joined
Jun 18, 2011
Messages
16
Hi All,
I have made a userform (Nothing special) and yesterday after I made it it seemed to work fine. Today when I click add button, It does put data onto sheet but a message box pops up saying Invalid Property Value. after initial press evrything I press brings up same message box.
I'm not sure what I have done as I was working on it a lot later than I should have been and might of changed something in my semi sleep lol.

Here is the code. It will be obvious to someone with knowledge i'm sure :eeek:

Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long
Dim ws As Worksheet
Set ws = Worksheets("WINES")


lRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row




If Trim(Me.cboCat.Value) = "" Then
Me.cboCat.SetFocus
MsgBox "Please enter a Category"
Exit Sub
End If


With ws
.Cells(lRow, 1).Value = Me.cboCat.Value
.Cells(lRow, 2).Value = Me.cboWinery.Value
.Cells(lRow, 3).Value = Me.cboBrand.Value
.Cells(lRow, 4).Value = Me.cboName.Value
.Cells(lRow, 5).Value = Me.cboVariety.Value
.Cells(lRow, 6).Value = Me.cboVintage.Value
.Cells(lRow, 7).Value = Me.chkqld.Value
End With


Me.cboCat.Value = ""
Me.cboWinery.Value = ""
Me.cboBrand.Value = ""
Me.cboName.Value = ""
Me.cboVariety.Value = ""
Me.cboVintage.Value = ""

Me.cboCat.SetFocus

End Sub

Private Sub cmdClose_Click()



Unload Me

End Sub


Private Sub cmdClear_Click()

Call UserForm_Initialize

End Sub




Private Sub UserForm_Initialize()
Dim cCat As Range
Dim cWine As Range
Dim cBrand As Range
Dim cName As Range
Dim cVariety As Range
Dim cVintage As Range

Dim ws As Worksheet
Set ws = Worksheets("Data")

For Each cCat In ws.Range("Cat")
With Me.cboCat
.AddItem cCat.Value

End With
Next cCat

For Each cWine In ws.Range("Winery")
With Me.cboWinery
.AddItem cWine.Value
End With
Next cWine

For Each cBrand In ws.Range("Brand")
With Me.cboBrand
.AddItem cBrand.Value
End With
Next cBrand

For Each cName In ws.Range("Name")
With Me.cboName
.AddItem cName.Value
End With
Next cName

For Each cVariety In ws.Range("Variety")
With Me.cboVariety
.AddItem cVariety.Value
End With
Next cVariety

For Each cVintage In ws.Range("Vintage")
With Me.cboVintage
.AddItem cVintage.Value
End With
Next cVintage


Me.cboCat.Value = ""

Me.cboCat.SetFocus

End Sub


Any help will be greatly appreciated ( including criticism of existing)

Cheers,
Adz
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
ALL GOOD!!

A few hours playing around and I got it.. for reference, Even tho one of my comboboxes needs to have data before adding, in the properties box, MatchRequired was set to true. Changed to false and works as good as gold.:biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,687
Members
452,938
Latest member
babeneker

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