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.

KLM NOPQ
Req.#PO#Vendor IDReqr.DateStatusClose PO?
F2015709PO# LLF20154096Louies LumberJ. Doe1/1/2015

-- removed inline image ---

<tbody>
</tbody>
Row 7
F2015713PO# LLF20155017Joes PaintJ. Doe1/1/2015

-- removed inline image ---

<tbody>
</tbody>
Row 8
F2015716PO# LLF20155111Marks LiquidsJ. Doe1/1/2015

-- removed inline image ---

<tbody>
</tbody>
Row 9
F2015721PO# LLF20155115Sams CarpetJ. Doe1/1/2015

-- removed inline image ---

<tbody>
</tbody>
Row 10

<tbody>
</tbody>



- JP
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,215,374
Messages
6,124,574
Members
449,173
Latest member
Kon123

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