Hi
I am having a mental blank I can't remember the code to do the following
I want to be able to add items to worksheets based on the worksheet selection in a Combobox
I dont want the Category name selected in the Combobox to be saved to the worksheet it is only used to select which worksheet the other data is to be saved to.
Any help would be appreciated
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets(",")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a Category
If Trim(Me.cboCategory.Value) = "" Then
Me.cboCategory.SetFocus
MsgBox "Please Select a Category"
Exit Sub
End If
'check for a Product
If Trim(Me.txtProduct.Value) = "" Then
Me.cboCategory.SetFocus
MsgBox "Please Enter a Product Description"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtProduct.Value
ws.Cells(iRow, 2).Value = Me.cboUnit.Value
ws.Cells(iRow, 3).Value = Me.txtPrice.Value
ws.Cells(iRow, 4).Value = Me.txtLabour.Value
'clear the data
Me.cboCategory.Value = ""
Me.txtProduct.Value = ""
Me.cboUnit.Value = ""
Me.txtPrice.Value = ""
Me.txtLabour.Value = ""
Me.cboCategory.SetFocus
End Sub
Bookmarks