• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

VBA Excel - Unable to add data from form into cells

I'm trying to learn Excel VBA (see attached spreadsheet) and am putting together a simple form that takes data input by users and places it into cells.

Why am I getting error message about variable not defined?
I defined it in the label and list controls.  Or am I wrong here?
vba-lesson.xlsm
0
brothertruffle880
Asked:
brothertruffle880
  • 2
1 Solution
 
als315Commented:
Change module to:
Private Sub cmdAdd_Click()
Cells(12, 1).Value = Me.txtEmpName.Value
Cells(12, 2).Value = Me.lsyEmpDept.Value
Cells(12, 3).Value = Me.txtEmpEarnings.Value
End Sub

Private Sub cmdClose_Click()
Me.Hide
End Sub

Open in new window

0
 
als315Commented:
Me - current object in VBA
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now