PDA

View Full Version : Printing specific records



YasserKhalil
07-28-2010, 06:35 AM
Hi guys
I have an attachment..
In Template Worksheet , I have three parts to be printed depending on the code of the employee
I want to print only those employees who have net salaries in Payroll worksheet
and don't print those who have zero or negative net salaries
I already wrote a code but it prints the employees with zero or negative net salaries
Hope to help me

Bob Phillips
07-28-2010, 06:51 AM
Not here it doesn't. Apart from the fact that you skip every 2nd and 3rd one, it only print positive salary employees.

YasserKhalil
07-28-2010, 06:57 AM
Here's the code

For I = 3 To 59 Step 3
If Sheets("Payroll").Cells(I, "X") > 0 Then
Sheets("Template").Cells(3, "C") = Sheets("Payroll").Cells(I, "A")
Sheets("Template").Cells(26, "C") = Sheets("Payroll").Cells(I + 1, "A")
Sheets("Template").Cells(49, "C") = Sheets("Payroll").Cells(I + 2, "A")
Sheets("Template").PrintPreview
End If
Next I


This code will print the employee with the code 1009
This is the point .. I don't want to include this employee
So this is my request to fix the code to exclude employees with zero or negative net salaries

Bob Phillips
07-28-2010, 07:07 AM
No it doesn't.

First, you start at row 3 at step 3, so you only look at rows 3, 6, 9, 12, etc., and 1009 is on row 11. Reason #1 why it doesn't print.

Secondly, if you change the code tos step 1, the test for greater than 0 fails on row 11. Reason #2 why it doesn't print.

YasserKhalil
07-28-2010, 10:55 AM
That means there's no solution for this problem or what??
Can I use a helper column and base the code on it?

Bob Phillips
07-28-2010, 03:13 PM
What problem? The error that you claim is happening is not happening. So there is no problem.