Link to home
Start Free TrialLog in
Avatar of Jim Coleman
Jim ColemanFlag for United States of America

asked on

Problems with custom Excel 2013 user form populating the spreadsheet.

I am building a QC tool and have a user form with a calendar select field, three combo boxes and two text entry fields.  Only the calendar populates to the correct cell.  I'm a newbie to VBA and can't figure out how to get the data from the Data Entry Form to the spreadsheet.  

The file is attached
QCSurvey.xlsm
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Your control names are wrong

Private Sub cmdadd_Click()
Dim erow As Long
With Sheet2
erow = .Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

.Cells(erow, 1).Value = Me.frmmachine.Text
.Cells(erow, 2).Value = Me.frmtime.Text
.Cells(erow, 3).Value = Me.tbplan.Text
.Cells(erow, 4).Value = tbactual.Text
.Cells(erow, 5).Value = frmcause.Text
End With

End Sub

Open in new window


Use names that indicate what type of control they are, not frmmachine, but cboMachine, tbxPlan.

Be wary of ActiveX calendars and date controls they will not work on all versions of Excel. There are non ActiveX examples here
Declare your varianles
Avatar of Jim Coleman

ASKER

Thanks for the quick response Roy.  I have read over it and am having trouble understanding because I've never done this before.  It's a foreign language to me.  I'll take some time with it and let you know how I've made out.
Just post back for help with what you don't understand.

Most important did you understand why the form wasn't working as you expected?

Have a look at the DatabaseForm example here. It's a free download and should help you learn more.
Roy:
Thank you for your help so far.  I have decided to withdraw (or delete) the question because it's more complicated than it needs to be.  I have gone with dropdown selections directly in the spreadsheet for the user.  This is only an interim solution until I purchase a full-up manufacturing system that will track machine up-time automatically without a need for user audits.

Thank you again.
It's not complicated at all. I corrected the errors in your code,.
I've requested that this question be deleted for the following reason:

I found a less complicated solution - simply adding dropdown boxes directly to the spreadsheet.  With only a few columns of data, this is quite simple.
ASKER CERTIFIED SOLUTION
Avatar of Roy Cox
Roy Cox
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial