Code to select a sheet to print

Stingrad

New Member
Joined
Jul 4, 2002
Messages
30
I have a list of engineers and a performance sheet that shows output. I can select and print each one individully but I have been trying to write code to do it automatically. It works fine but only prints the same sheet for all. There are 2 sheets 1 if they have done well and one if they have not. I need it to print the sheet based on how they did. The target is 100% and is in a range called "gross" the sheets to select from are worse (less than 100%) or better (more than 100%). The code I have is here as you can see the two lines that I have tried seem to be ok but only print out the worse sheet for all.
[/code]
Sub PrintEng_00()
'Determines how many engineers there are on selected patch
Sheets("Sheet2").Select
If Range("NumberOfEng").Value = 1 Then PrintEng_01
If Range("NumberOfEng").Value = 2 Then PrintEng_02
If Range("NumberOfEng").Value = 3 Then PrintEng_03
If Range("NumberOfEng").Value = 4 Then PrintEng_04
If Range("NumberOfEng").Value = 5 Then PrintEng_05
If Range("NumberOfEng").Value = 6 Then PrintEng_06
If Range("NumberOfEng").Value = 7 Then PrintEng_07
If Range("NumberOfEng").Value = 8 Then PrintEng_08
If Range("NumberOfEng").Value = 9 Then PrintEng_09
If Range("NumberOfEng").Value = 10 Then PrintEng_10
If Range("NumberOfEng").Value = 11 Then PrintEng_11
Sheets("Sheet2").Select
Range("Eng_Choice").Select
ActiveCell.FormulaR1C1 = "1"
Range("A1").Select
End Sub

Sub PrintEng_01()
' 1 Engineer on the patch
Range("Eng_Choice").Select
ActiveCell.FormulaR1C1 = "1"
If Range("gross").Value >= 100 Then Sheets("Worse").Select
If Range("gross").Value <= 100 Then Sheets("Better").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet2").Select
Range("A1").Select
End Sub
Sub PrintEng_02()
' 2 Engineer on the patch
PrintEng_01
Range("Eng_Choice").Select
ActiveCell.FormulaR1C1 = "2"
If Range("gross").Value >= 100 Then Sheets("Worse").Select
If Range("gross").Value <= 100 Then Sheets("Better").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet2").Select
Range("A1").Select
End Sub

I hope that is clear enough
Thanks
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Isn't it simply the number you are using:

If the cell value is formated as percentage you need to use >= 1 or <1. Also the procedure may be confused by your use of >=100 and <=100 one of these needs to be greater than or less than (i.e. both cannot be equal to).

Hope this makes sense.

Jim
 
Upvote 0
:) Thanks it was just the fact of using 1 after the hard work writing it I can not belive how simple it was. Thanks again
 
Upvote 0

Forum statistics

Threads
1,221,692
Messages
6,161,341
Members
451,697
Latest member
pedroDH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top