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
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
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
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