Getting Data from a worksheet to a form - and back again

D

Dan

Hello,

I am new to VBA (Excel 2007), and am struggling with the syntax to get data
from a form into a worksheet.

The scenario:
1. The 'Contacts' worksheet contains customer contacts - name, address,
phone, etc. The user scrolls around, looking for someone to call. When they
find one,
2. Run a macro that calls a module to pull the current row's data into a
form. This is working.
3. Add contact info (e.g. who you talked to, date/time, notes) to the form;
then
4. Click the 'AddContact' command button on the form, which will
5. Add a new row to the 'Contacts' worksheet, with the data collected on
the form.

Steps 1-3 are working. Step 2 has code like this:

Selection.Font.Bold = True

' Get the data from the spreadsheet to the form
ContactForm.Company = Cells(ActiveCell.Row, 2)
ContactForm.Contact = Cells(ActiveCell.Row, 4)
ContactForm.Address = Cells(ActiveCell.Row, 5)
...
ContactForm.AttemptName = Cells(ActiveCell.Row, 4)
ContactForm.AttemptDate = Date
ContactForm.AttemptTime = Time
ContactForm.AttemptPhone = Cells(ActiveCell.Row, 11)

ContactForm.Show

I am struggling with the syntax to pull the data from the form into the
spreadsheet (via the on_click event in the command button).

Where can I go to find syntax examples?

Thanks in advance,

--Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top