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


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

End If

Next i

End Sub





Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

One thought on “How to Print Non Blank Pay Slips”

  1. 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

Leave a Reply

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