Macro to copy data to another tab, save as pdf and send as email attachment

manona

New Member
Joined
Mar 22, 2016
Messages
40
Hi!

I have a nice little challenge for you's (ok maybe it's not a challenge for you but it is for me! :confused:).

I'd like to create a code that will 0) will go look if there is a certain value in a column cell, 1) if there is a 'Yes' in that column, copy values from certain cells to blank merged cells in another tab, 2) save second tab as PDF using a cell value as title, and 3) send PDF as mail attachment with a cell value as email address, 4) clear merged cells, and 5) enter "Yes" in a specific column of the first tab. Is this possible?

Here is the context:
The first tab has raw information from a form that was completed and submitted. The second tab is a template for a receipt with blank, merged cells where information will be copied. I've added a column at the end of the first tab, titled 'Receipt sent?'. This is because new raw information will be added weekly. So the idea is that whenever the user goes in the sheet, pastes the new information, they can press a button at the top that will run the macro, and the macro will go and do steps 1-5 above for all rows that do NOT have 'Yes' in the last column.

Once a macro is done, I would like it to go look for the next row that has a value in column A, but does not have the 'Yes' in the last column. When it has completed all rows, to prop the message 'Receipts have been created for all new entries'.

Here are the details:

original tab ('Raw')to be coped in receipt tab ('Receipt)
NameB2 +B13 (merged cells)
AddressE2 +B14 (merged cells)
LotG2 +B19 (merged cells)
ServiceH2 +B23 (merged cells)
DaysI2 +B27 (merged cells)
DateL2 +E29 (non-merged cell)
PaymentF2 +H29 (non-merged cell)

<tbody>
</tbody>

Title of the PDF document: value in column B of the row

Email address to include in email message: value in D of the row

MAIL: if it can be done directly via gmail that would be amazing. If not, Outlook.

BONUS: if there is a way we can also include a message in the VBA code so that when the email is generated, we have the email address in the 'TO' field, we have a generic message prepared, and the PDF as attachment?

OPTION: some people have not provided an email address, which in that case the value is exactly "n/a". In that case, the macro can skip generating the email. or it can simply ignore and we will manually close the email and send physical mail to these recipients. whatever is easiest.



I have before created a macro to copy values to another sheet and then clear the cells, but I was not dealing with some merged cells, and I wasn't generating PDF or sending email. Your help is very very appreciated! :) even if it's parts of the solution (only PDF, only mail, only code for merged cell, etc.). I can piece it together afterwards.

Thanks in advance!!

PS I hope this makes sense. Please ask if there are unclear items!

Manon
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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