Email and Print code for Userform

excelbiff

New Member
Joined
Feb 21, 2011
Messages
8
Hi guys,

I have a userform with a button labeled 'Submit'. When this button is pressed it populates cells within my worksheet with data within text boxes on the userform.

I would also like the same button to bring up an email template, to be sent to a particular email address, an to have fields populated with the same data.

The email address will always be the same no matter what.

The code I have at the moment is:

Code:
Private Sub cmdSubmit_Click()
ActiveWorkbook.Sheets("SIRs").Activate

    Range("C6").Select

    Do

If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select

End If

Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = txtSIRNo.Value
ActiveCell.Offset(0, 1) = txtDescription.Value
ActiveCell.Offset(0, 2) = txtSNOW.Value
ActiveCell.Offset(0, 3) = txtOriginator.Value
ActiveCell.Offset(0, 4) = txtItem.Value
ActiveCell.Offset(0, 5) = txtSerNo.Value
ActiveCell.Offset(0, 6) = txtPartNo.Value
ActiveCell.Offset(0, 7) = txtDate.Value
ActiveCell.Offset(0, 8) = txtStartTime.Value
ActiveCell.Offset(0, 10) = txtStopTime.Value
ActiveCell.Offset(0, 12) = txtConditions.Value
ActiveCell.Offset(0, 13) = txtDowntimeItem.Value
ActiveCell.Offset(0, 14) = txtDowntimeFPDS.Value
ActiveCell.Offset(0, 15) = txtReplacement.Value
ActiveCell.Offset(0, 16) = txtTask.Value
ActiveCell.Offset(0, 17) = txtError.Value
ActiveCell.Offset(0, 18) = txtMethod.Value
ActiveCell.Offset(0, 19) = txtAction.Value
ActiveCell.Offset(0, 20) = txtHandbookReference.Value
ActiveCell.Offset(0, 21) = txtProcedure.Value
ActiveCell.Offset(0, 22) = txtIssues.Value
ActiveCell.Offset(0, 23) = txtAttachments.Value
ActiveCell.Offset(0, 24) = txtRank.Value
ActiveCell.Offset(0, 25) = txtInformation.Value
ActiveCell.Offset(0, 26) = txtContinuation.Value
If opInoperable = True Then
ActiveCell.Offset(0, 9).Value = "Inoperable"
ElseIf opDegraded = True Then
ActiveCell.Offset(0, 9).Value = "Degraded"
Else
ActiveCell.Offset(0, 9).Value = "Unaffected"
End If
If opSparesYes = True Then
ActiveCell.Offset(0, 11).Value = "Yes"
Else
ActiveCell.Offset(0, 11).Value = "No"
End If

Range("C6").Select

Unload Me
End Sub
How can I manipulate this code to do what I want?

I would also like a print button on the userform whereby when pressed the same data from the userfom populates fields in a word doc for me to print.

Cheers guys.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top