ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting Data from a worksheet to a form - and back again (https://www.excelbanter.com/excel-programming/438025-getting-data-worksheet-form-back-again.html)

dan

Getting Data from a worksheet to a form - and back again
 
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


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com