E-mail Excel worksheet based upon selection of combo box

M

MWerblan

I'm using the form toolbar combo-box with a pre-defined list that is
on a hidden sheet.

The list starts at 1, not 0.

The goal that I am trying to reach is if a particular plant is
selected in the combo-box (plant 1, plant 2, plant 3), when the e-mail
button is clicked, it will send it to the person under that plant.

I tried several different options including:

Try 1:
If ActiveSheet.Shapes("dd_plant").ListIndex = 2 Then
.SendMail "(e-mail address removed)", "DP Routing Create/
Update/Change Form - Monroe", yes
ElseIf ActiveSheet.Shapes("dd_plant").ListIndex = 3 Then
.SendMail "(e-mail address removed)", "DP Routing Create/
Update/Change Form - Auburn", yes
ElseIf ActiveSheet.Shapes("dd_plant").ListIndex = 4 Then
.SendMail "(e-mail address removed)", "DP Routing Create/
Update/Change Form - Jeannette", yes
ElseIf ActiveSheet.Shapes("dd_plant").ListIndex = 5 Then
.SendMail "(e-mail address removed)", "DP Routing Create/
Update/Change Form - Dupo", yes
ElseIf ActiveSheet.Shapes("dd_plant").ListIndex = 6 Then
.SendMail "(e-mail address removed)", "DP Routing Create/
Update/Change Form - Columbus", yes
Else
On Error GoTo 0
.Close SaveChanges:=False
End If

Try 2:

If ActiveSheet.Shapes("dd_plant") = 2 Then
.SendMail "(e-mail address removed)", "Create/Update/Change Form - Plant
1", yes
ElseIf ActiveSheet.Shapes("dd_plant") = 3 Then
.SendMail "(e-mail address removed)", "Create/Update/Change Form - Plant
2", yes
End If

Try 2:

If ActiveSheet.Shapes("dd_plant").ListIndex = 2 Then
.SendMail "(e-mail address removed)", "Create/Update/Change
Form - Plant 1", yes
ElseIf ActiveSheet.Shapes("dd_plant").ListIndex = 3 Then
.SendMail "(e-mail address removed)", "Create/Update/Change Form - Plant
2", yes
End If

I have used the following code for resetting the list to the first
field of the selected, which is blank:

ActiveSheet.Shapes("dd_plant").Select
With Selection
.ListIndex = 1
End With

Is it possible to set a selection based upon the combo-box who the e-
mail goes to?
 
R

Ron de Bruin

You can try this

Dim MailStr As String

Select Case ActiveSheet.Shapes("dd_plant").ListIndex
Case 2: MailStr = "(e-mail address removed)"
Case 3: MailStr = "(e-mail address removed)"
Case 4: MailStr = "(e-mail address removed)"
Case 5: MailStr = "(e-mail address removed)"
End Select

Then use MailStr in the SendMail code line
 

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