How to Print Non Blank Pay Slips

How to print non blank pay slips and avoid printing blank pay slips using VBA. A user has a large database of employees and every month he creates pay slips using Vlookup and prints them. Due to non-availability of complete details about an employees salaries and perks he may need to keep the pay slip blank during the processing and this blank pay slip may occur anywhere within the hundreds or thousands of pay slips he prints. He would like to avoid the printing of such blank pay slips due to obvious reasons. watch how the video shows a simple ‘for next’ looping macro that solves the problem quickly and easily:

Watch this video on YouTube.

Here’s the complete VBA macro code:

Sub printingSlips()

Dim i As Long

For i = 1 To 1750

If Cells(i, 1) = “Empl. ID” And Cells(i + 1, 1) <> “” And Cells(i + 1, 6) <> “” Then

Range(Cells(i – 6, 1), Cells(i + 14, 6)).Select

‘Selection.PrintPreview

ActiveSheet.Range(Cells(i – 6, 1), Cells(i + 14, 6)).PrintPreview

End If

Next i

End Sub

 

 

 

 

One thought on “How to Print Non Blank Pay Slips

  1. Paul Kangethe Gitau

    hello sir

    I have been unsuccessfully trying to send text messages from excel vba to given contacts when the reminder is due i.e. remaining 3 days to the date in the excel column.

    please help me how to go about this with the excel code.

    kind regards,

    Paul Kangethe

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *