VBA code for emailing payslips from excel source file as pdf's to multiple employees.

johnlink

New Member
Joined
Nov 24, 2017
Messages
10
Hi I am rather new to VBA but have used Excel for some time. I have an excel file dump of employee payslips each week. All employees are contained in the one worksheet - structure of data is regular so a search for a key cell value eg "Earnings Summary" at the start of each payslip then create a range possibly using offset and an end marker at the next down "Earnings Summary" cell. From this selected range I then need to issue an email to the employee (email address is stored in another worksheet can be a vlookup) and attach a pdf of the payslip range selected. Following this I need the code to loop on down to the next payslip and do the same until the end of the file is reached. Needs to be fully automated if possible so can be done each payday by others. Also the worksheet is locked so may need to do a "save as" copy at the start of the code. Hope this makes sense and I look foward to any helpful replies from others who may have solved this. Many thanks. Johnlink.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I have decided to break down the task into steps. I am attaching the data dump file image (all names changed for privacy). First step I need to have a macro loop through the file and find and delete all the data shaded yellow for ea employee per the yellow shaded example for 1st employee.
First yellow patch deletion can be a bunch of rows selected and deleted according to their position between the key marker cells - Earning Details A11 & Leave Accrued A27 (for 1st employee). Next yellow patch will need a range of cells selected and a CLEAR ALL exectued. Then the last yellow lot will be a set of rows to delete. Then cycle on to the next employee.
Thanks.

EDIT:
Table can be seen here
https://www.mrexcel.com/forum/test-here/1096924-testing-image-my-worksheet.html
 
Last edited by a moderator:
Upvote 0
Cross posted https://chandoo.org/forum/threads/vba-code-for-emailing-payslips.41633/

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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