KEMBAR78
CustomerForm Code | PDF
0% found this document useful (0 votes)
8 views1 page

CustomerForm Code

This document contains a VBA code snippet for a form that submits customer information to an Excel worksheet named 'Customers'. It captures details such as first name, last name, email, phone, company, status, and notes, and adds them to the next available row in the worksheet. The code also includes a message box to confirm successful addition and a cancel button to unload the form.

Uploaded by

ashugarg6547
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

CustomerForm Code

This document contains a VBA code snippet for a form that submits customer information to an Excel worksheet named 'Customers'. It captures details such as first name, last name, email, phone, company, status, and notes, and adds them to the next available row in the worksheet. The code also includes a message box to confirm successful addition and a cancel button to unload the form.

Uploaded by

ashugarg6547
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Private Sub btnSubmit_Click()

Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Customers")

Dim nextRow As Long


nextRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1

ws.Cells(nextRow, 1).Value = nextRow - 1 ' Customer ID


ws.Cells(nextRow, 2).Value = txtFirstName.Value
ws.Cells(nextRow, 3).Value = txtLastName.Value
ws.Cells(nextRow, 4).Value = txtEmail.Value
ws.Cells(nextRow, 5).Value = txtPhone.Value
ws.Cells(nextRow, 6).Value = txtCompany.Value
ws.Cells(nextRow, 7).Value = txtStatus.Value
ws.Cells(nextRow, 8).Value = Date ' Created Date
ws.Cells(nextRow, 9).Value = "" ' Last Contacted
ws.Cells(nextRow, 10).Value = txtNotes.Value

MsgBox "Customer added successfully!", vbInformation


Unload Me
End Sub

Private Sub btnCancel_Click()


Unload Me
End Sub

You might also like