UserForm has errors -need help

txguy

New member
Joined
Nov 9, 2021
Messages
1
Reaction score
0
Points
0
Excel Version(s)
Excel 365
I'm new to both userForm creation and VBA coding. I did a userForm but am seeing errors in it. Not sure how to correct them. Any help would be appreciated greatly since I need to get this doen soonest. The Excel File is attached. Just need it to work. Thank you.
 

Attachments

  • ROIFORM.xlsm
    39.8 KB · Views: 4
Here is a sample database attached. Study the code and it can be applied to your project with some simple adjustments.

Code:
Option ExplicitPrivate Sub btnCancel_Click()
    Unload Me
End Sub


Private Sub btnOK_Click()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Dim newRow As Long
    
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    'The next two lines can be expanded as many times as needed for all the entry fields in your project
    
    ws.Cells(newRow, 1).Value = Me.txtFirstName.Value
    ws.Cells(newRow, 2).Value = Me.txtSurname.Value
    
End Sub
Sub CommandButton1_Click()
    Selection.EntireRow.Delete
End Sub
 

Attachments

  • Simple Database.xlsm
    20.8 KB · Views: 5
Back
Top