Copying values to buffer and sending an email

MrJimi

New Member
Joined
Sep 14, 2015
Messages
1
Hello Experts!
I've been having a problem with creating mail sending macro from my report using MS Office 2010.

I have come up with an idea to put header of the report in separate sheet “buffer” and then create a macro which will copy row’s range underneath it and then send it all in msg body. It seems that it will make it less fragile.
I need to have AF column active in a main sheet. For example: When double-clicking on AF2 cell, Range("A2:AD2") should copy over to “buffer” sheet. It looks like:
Code:
Range("A2:AD2").Select
Selection.Copy
Sheets("buffer").Select
Range("A3").Select
ActiveSheet.Paste
This macro needs to be applied to each row.
Double-click on AE2 cell copy Range("A2:AD2"), And paste it to the same place A3 in “buffer” sheet and send email.
Double-click on AE3 cell copy Range("A3:AD3"), And paste it to the same place A3 in “buffer” sheet and send email.
Double-click on AE4 cell copy Range("A4:AD4"), And paste it to the same place A3 in “buffer” sheet and send email.
And so on…
It seems to be easy but don’t know how to make it possible.
Second part which is send email does not require code to be changed each time when double click is performed. That is why “buffer” has been created. This should make it easier.
I have managed to define recipients and email details using following:
Code:
DLsTo = wTarget.Worksheets("buffer").Cells(3, 29)
DLsCC = wTarget.Worksheets("buffer").Cells(3, 28)
Subjects = wTarget.Worksheets("buffer").Cells(3, 27)
Messagetext = wTarget.Worksheets("buffer").Cells(20, 2)
'Remove Formulas
wTarget.Worksheets("buffer").Range("A1:AD3").Copy
wTarget.Worksheets("buffer").Range("A1:AD3").PasteSpecial xlPasteValues


'Create Email
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = DLsTo
.CC = DLsCC
.Bcc = DLsBCC
.Subject = Subjects
.Body = Messagetext

I’ve been told that this forum is the best place to ask for help.
Experts, how to make first part applicable for each rows and how to merge those lines into smoothly working macro?
It is a hard nut to crack for me. I am learning every day something new about Excel VBA but the clock is ticking and I am asking for your help.

Thank you so much in advance!
MrJimi
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,217,188
Messages
6,135,106
Members
449,911
Latest member
Omarahmed99

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