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:
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