Thursday, August 17, 2006

Getting data from your form to your spreadsheet

Last week we had a play with creating our own customised forms, with text boxes, comboboxes, labels and other options... but one question that many people asked was "How do I get the info from the form and into the spreadsheet?" That's the first thing we'll see this week!

Open up your StudentResults Spreadsheet that we started last week and:
  • Go into the vba editor
  • Edit your userform (it should be called frmStudentDetails or something similar)
  • Double-click on the OK button to add a click-event for your OK button,
Add the following code to your OK button's click function:
  • Cells(1,1).Select
  • ActiveCell = txtFirstName 'Or whatever your field is called
  • ActiveCell.Offset(1,0) = txtLastName
Test out your form to see what it does... you'll find that it's not exactly what you had planned. See if you can modify the code so that the info from the form goes into the right cells!

Now we've got one remaining problem... our data is getting from our form to our spreadsheet, but it always going into the same row... how are we going to solve this?

0 Comments:

Post a Comment

<< Home