Excel 2010 - Use a Button on each row to send e-mail with string of data from row - help wanted!

truchiller

New Member
Joined
Jan 11, 2010
Messages
4
Team,

I am using excel as a checkbook and would like to be able to
  • Create a function e-mail button - specific to each row line item
  • Assign an e-mail action to the button when clicked
  • Once the button is clicked - it pastes the word "Closed" into a specific cell P7:P375 - pending which row is active
  • The e-mail would format the following:
    • Open Outlook
    • Autofill To: address@address.com -
    • Autofill Cc: address@address.com
    • Subject: "Action to Close Purchase Order"
    • Body: "Team, please close and pay the following purchase order:" "Stringdata" (Information comes from L7:L375 & M7:M375 pending which row is active for sending e-mail) - so the button references only the data in that line in which the button is sitting on) "Thank you"
  • For example: I want the following to happen
    • Click Close PO Button on Row 7
    • P7 Status now reads "Closed"
    • E-mail Opens up
    • To: Address@address.com
    • Cc: Address@address.com
    • Subject: Action to Close Purchase Order
    • Body: "Team, please close and pay the following purchase order: PO#LLF20154096 - Louise Lumber." "Thank you."
    • Click Send E-mail
    • Now "Close PO" button grays out Q7
  • And do a separate e-mail for each line item - not always in order either - so row 7, then row 9 (3) days later
  • I can create a new sheet as well for e-mail addresses as these may change and need to be updated.

I have only found VB Scripting for sending whole page or workbook and not data strings specific. Any help is much appreciated -I am beyond my excel limitations now.

[TABLE="width: 533"]
<tbody>[TR]
[TD="width: 86, bgcolor: silver"]K[/TD]
[TD="width: 118, bgcolor: silver"]L[/TD]
[TD="width: 118, bgcolor: silver"]M [/TD]
[TD="width: 84, bgcolor: silver"]N[/TD]
[TD="width: 71, bgcolor: silver"]O[/TD]
[TD="width: 76, bgcolor: silver"]P[/TD]
[TD="width: 92, bgcolor: silver"]Q[/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: silver"]Req.#[/TD]
[TD="bgcolor: silver"]PO#[/TD]
[TD="bgcolor: silver"]Vendor ID[/TD]
[TD="bgcolor: silver"]Reqr.[/TD]
[TD="bgcolor: silver"]Date[/TD]
[TD="bgcolor: silver"]Status[/TD]
[TD="bgcolor: #BFBFBF"]Close PO?[/TD]
[TD="bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: #F2DCDB"]F2015709[/TD]
[TD="bgcolor: #F2DCDB"]PO# LLF20154096[/TD]
[TD="bgcolor: #F2DCDB"]Louies Lumber[/TD]
[TD="bgcolor: #F2DCDB"]J. Doe[/TD]
[TD="bgcolor: #F2DCDB, align: right"]1/1/2015[/TD]
[TD="bgcolor: #F2DCDB"][/TD]
[TD="width: 92, bgcolor: #FCD5B4"]

<tbody>
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]
-- removed inline image ---
[/TD]
[TD="width: 3, bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

</tbody>
[/TD]
[TD="bgcolor: transparent"]Row 7[/TD]
[/TR]
[TR]
[TD="bgcolor: #F2DCDB"]F2015713[/TD]
[TD="bgcolor: #F2DCDB"]PO# LLF20155017[/TD]
[TD="bgcolor: #F2DCDB"]Joes Paint[/TD]
[TD="bgcolor: #F2DCDB"]J. Doe[/TD]
[TD="bgcolor: #F2DCDB, align: right"]1/1/2015[/TD]
[TD="bgcolor: #F2DCDB"][/TD]
[TD="width: 92, bgcolor: #FCD5B4"]

<tbody>
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]
-- removed inline image ---
[/TD]
[TD="width: 2, bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

</tbody>
[/TD]
[TD="bgcolor: transparent"]Row 8[/TD]
[/TR]
[TR]
[TD="bgcolor: #F2DCDB"]F2015716[/TD]
[TD="bgcolor: #F2DCDB"]PO# LLF20155111[/TD]
[TD="bgcolor: #F2DCDB"]Marks Liquids[/TD]
[TD="bgcolor: #F2DCDB"]J. Doe[/TD]
[TD="bgcolor: #F2DCDB, align: right"]1/1/2015[/TD]
[TD="bgcolor: #F2DCDB"][/TD]
[TD="width: 92, bgcolor: #FCD5B4"]

<tbody>
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]
-- removed inline image ---
[/TD]
[TD="width: 2, bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

</tbody>
[/TD]
[TD="bgcolor: transparent"]Row 9[/TD]
[/TR]
[TR]
[TD="bgcolor: #F2DCDB"]F2015721[/TD]
[TD="bgcolor: #F2DCDB"]PO# LLF20155115[/TD]
[TD="bgcolor: #F2DCDB"]Sams Carpet[/TD]
[TD="bgcolor: #F2DCDB"]J. Doe[/TD]
[TD="bgcolor: #F2DCDB, align: right"]1/1/2015[/TD]
[TD="bgcolor: #F2DCDB"][/TD]
[TD="width: 92, bgcolor: #FCD5B4"]

<tbody>
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]
-- removed inline image ---
[/TD]
[TD="width: 3, bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

</tbody>
[/TD]
[TD="bgcolor: transparent"]Row 10[/TD]
[/TR]
</tbody>[/TABLE]



- JP
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I would reconsider adding the button per row (for over 350 rows) with specific code for each button. The filesize and code required would be way larger than needed.

Instead write code to this effect on a module
Code:
Sub SendEmail(Row As Long)
Dim OutApp As Object
Dim OutMail As Object
Dim msg As String
On Error GoTo cleanup
msg = "Team, please close and pay the following purchase order: " & _
    Range("K" & Row) & " - " & Range("M" & Row) & ".  Thank you."
Set OutApp = CreateObject("Outlook.Application")
With Application
    .EnableEvents = False
    .ScreenUpdating = False
End With
Set OutMail = OutApp.createitem(0)
With OutMail
    .to = "[EMAIL="Address@Address.com"]Address@Address.com[/EMAIL]"
    .cc = "[EMAIL="Address2@Address.com"]Address2@Address.com[/EMAIL]"
    .Subject = "Action to Close Purchase Order"
    .Body = msg
    .Display  'Or use Send
End With
Range("P" & Row).Value = "Closed"
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
With Application
    .EnableEvents = True
    .ScreenUpdating = True
End With
End Sub
Then you will need something to trigger the macro to run. I recommend a double-click event in column P. Under Excel Objects and the Sheet you are wanting to watch changes, insert something like this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Targ As Range
Set Targ = Intersect(Target, Range("P7:P375"))
'Doubleclick in column P to trigger macro
If Not Targ Is Nothing Then
    SendEmail Target.Row
    Cancel = True       'undo the doubleclick effect if macro triggered
End If
End Sub

for more: www.rondebruin.nl/win/s1/outlook/mail.htm
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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