VBA for employee payslips pdf and email

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question


    I want generate All Employee payslip in PDF on 1 Button=VBA codes gives error PLS HELP


    want to create VBA for for employee payslips excel to pdf for range of cells and send email in one button

  • Your "VBA CODE" refers to sheets that don't exist in your workbook. Please explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data. It would also help if you include a sheet that shows what your email should look like.

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Carim

    Changed the title of the thread from “want to create VBA for for employee payslips pdf and email” to “VBA for employee payslips pdf and email”.
  • Do you want to create a PDF of the payslip for all employees, save that pdf and send it as an email attachment to each employee?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Carim

    Added the Label Cross Post
  • Try the attached, click the button on the "Payroll calculator" sheet (after updating the Period in cell W2).


    The code will create a Salary Slip for all employees who have worked at least one day during the month (employee has a value greater than 0 in Payroll calculator Column G). A PDF will be created and saved to a sub-folder in the same folder as the Salary OTP-2022 workbook, if the sub-folder does not exist the code will create it. That PDF file will then be emailed to the employee.


    Code assigned to the button

    Note that I added a column to the Employee information sheet for the email address of each employee. If an employee does not have an email address entered then his/her Salary Slip will be printed rather than emailed.


    Depending on computer system the code will take approximately 45 seconds to create and email all the salary slip pdfs.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!