EDIT CODE

gleamng

Board Regular
Joined
Oct 8, 2016
Messages
98
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Good evening house
please i need help with the macro below,
the macro generate payslip for each row (that is if i have 10 records, it created 10 pdf files
what i want now is for the macro to generate one single file with each record per page (i.e 10pages pdf file)

thanking you for your help


VBA Code:
Option Explicit

Sub Slip()
On Error Resume Next
MkDir "C:\Payslip"
Sheet5.Range("A1:D32").ExportAsFixedFormat xlTypePDF, Filename:="C:\Payslip\" & Sheet5.Range("F3").Value, openafterpublish:=False
End Sub

Sub PDF_PAYSLIP()
Application.ScreenUpdating = False
On Error Resume Next
MkDir "C:\Payslip"
Dim x As Long
Dim y As Long
x = Sheet2.Range("A" & Rows.Count).End(xlUp).Row
For y = 4 To x
If Len(Sheet2.Cells(y, 1).Value) > 0 Then
Sheet5.Range("F3").Value = Sheet2.Cells(y, 1)
End If
Call Slip
Next y

MsgBox "Pay Slips successfully generated"
End Sub
 
I can see what you want now and the only thing I can think of at the moment is to copy over Sheet5 details into a separate sheet and put page breaks in-between to get the result you desire but with the Excel limit on page breaks I consider this impractical with 20000 employees.

Due to the above I am leaving this thread and hopefully someone else will come up with a more practical solution.
I am a bit surprised that with >20000 employees you haven't got specialised payroll software.
 
Upvote 0
Solution

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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