Author Archives: Dinesh Kumar Takyar

About Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! 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: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

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