dleister
New Member
This is the first userform I created and I want it to add data to a worksheet "Commit" however the code runs but it does not appear to be adding any data.
here is my userform code, if anyone has a suggestion it would be greatly appreciated since I need this form to go live to the client very soon. Thanks!
Private Sub CmdAdd_Click()
Dim ws As Worksheet
Dim addme As Range
'set the variable
Set ws = Worksheets("Commit")
'set variable for the destination
Set addme = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
If Me.cboEnteredBy.Value = "" Or Me.cboPayee.Value = "" Or Me.tbAmt.Value = "" Or Me.cboProject.Value = "" Or Me.cboAcctCode.Value = "" Then
MsgBox "There is insufficient data. Madatory fields must be added (*)", vbExclamation, "Mandatory fields are incomplete"
Exit Sub
End If
With ws
addme.Offset(0, 1).Value = Me.TbDate
addme.Offset(0, 2).Value = Me.cboEnteredBy
addme.Offset(0, 3).Value = Me.cboPayee
addme.Offset(0, 4).Value = Me.tbAmt.Value
addme.Offset(0, 5).Value = Me.cboProject
addme.Offset(0, 6).Value = Me.cboAllocProj
addme.Offset(0, 7).Value = Me.cboAcctCode
addme.Offset(0, 8).Value = Me.tbDescr
addme.Offset(0, 9).Value = Me.tbNotes
End With
'return to sheet
Sheet1.Select
'reset the form
Unload Me
FrmCommit_Add.Show
'update the sheet
Application.ScreenUpdating = True
Unload Me
End Sub
here is my userform code, if anyone has a suggestion it would be greatly appreciated since I need this form to go live to the client very soon. Thanks!
Private Sub CmdAdd_Click()
Dim ws As Worksheet
Dim addme As Range
'set the variable
Set ws = Worksheets("Commit")
'set variable for the destination
Set addme = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
If Me.cboEnteredBy.Value = "" Or Me.cboPayee.Value = "" Or Me.tbAmt.Value = "" Or Me.cboProject.Value = "" Or Me.cboAcctCode.Value = "" Then
MsgBox "There is insufficient data. Madatory fields must be added (*)", vbExclamation, "Mandatory fields are incomplete"
Exit Sub
End If
With ws
addme.Offset(0, 1).Value = Me.TbDate
addme.Offset(0, 2).Value = Me.cboEnteredBy
addme.Offset(0, 3).Value = Me.cboPayee
addme.Offset(0, 4).Value = Me.tbAmt.Value
addme.Offset(0, 5).Value = Me.cboProject
addme.Offset(0, 6).Value = Me.cboAllocProj
addme.Offset(0, 7).Value = Me.cboAcctCode
addme.Offset(0, 8).Value = Me.tbDescr
addme.Offset(0, 9).Value = Me.tbNotes
End With
'return to sheet
Sheet1.Select
'reset the form
Unload Me
FrmCommit_Add.Show
'update the sheet
Application.ScreenUpdating = True
Unload Me
End Sub