![]() |
||||
|
|
||||
UserForm to Automate Calculations and Validate
Data
|
||||
| Excel 2007 |
Excel 2003 |
Macros Excel 2007 |
Macros Excel 2003 |
Excel 2010 |
| About Us |
Free Ebook |
Offline Training |
Blog |
Interactive Training |
|
|
Let's have a closer look at the new code for the command button of the improved user-form. Private Sub cmdAddData_Click() Dim benefits, total As Single If Me.txtName.Value = "" Then MsgBox "Please enter a name", vbExclamation, "Employee Data" Me.txtName.SetFocus End If Range("A5") = txtName.Text If Not IsNumeric(Me.txtSalary.Value) Then MsgBox "The Amount box must contain a number.", vbExclamation, "Employee Data" Me.txtSalary.SetFocus End If Range("B5") = txtSalary.Value benefits = txtSalary.Value * 0.5 Range("C5") = benefits total = txtSalary.Value + benefits Range("D5") = total End Sub
Watch the video below to understand the details. |
|||
|
|
||||
| Excel 2007 | Excel 2003 | Macros Excel 2007 | Macros Excel 2003 | Excel 2010 |
| About Us | Free Ebook | Offline Training | Blog | Interactive Training |