Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a workbook that has 24 tabs on it. It is used to evaluate people. An
evaluator will evaluate up to 24 people. But not the max all the time. If thhey only do say 10, then I only want to print 10 from that workbook. The I might open 16 workbooks on an evaluation day and need to print only the worksheeets that have been typed onto. Is there a way to do an if command in a macro? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Certainly it's possible. The key would be to determine one (or more) cell
addresses that would be empty unless the sheet has been used to record an evaluation. The code below presumes 1 cell (A1) would meet that requirement. You can change that if required. To put the code into a workbook, open the workbook, press [Alt]+[F11] and then, from the Visual Basic Editor menu, choose Insert and Module and copy and paste (and modify) the code into it. Run the macro from Tools | Macro | Macros. This code prints each sheet individually, so they would all be numbered page 1 if you have page numbering set up in the header or footer. Sub PrintUsedSheets() Const keyCell = "A1" 'change to must be used cell address Dim anySheet As Worksheet For Each anySheet In ThisWorkbook.Worksheets If Not IsEmpty(anySheet.Range(keyCell)) Then anySheet.PrintOut copies:=1 End If Next End Sub "Brian" wrote: I have a workbook that has 24 tabs on it. It is used to evaluate people. An evaluator will evaluate up to 24 people. But not the max all the time. If thhey only do say 10, then I only want to print 10 from that workbook. The I might open 16 workbooks on an evaluation day and need to print only the worksheeets that have been typed onto. Is there a way to do an if command in a macro? |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
That hit the nail on the head. With what I do at work I would pull my hair
out if not for this website. Thanks for all you do MVP'ers "JLatham" wrote: Certainly it's possible. The key would be to determine one (or more) cell addresses that would be empty unless the sheet has been used to record an evaluation. The code below presumes 1 cell (A1) would meet that requirement. You can change that if required. To put the code into a workbook, open the workbook, press [Alt]+[F11] and then, from the Visual Basic Editor menu, choose Insert and Module and copy and paste (and modify) the code into it. Run the macro from Tools | Macro | Macros. This code prints each sheet individually, so they would all be numbered page 1 if you have page numbering set up in the header or footer. Sub PrintUsedSheets() Const keyCell = "A1" 'change to must be used cell address Dim anySheet As Worksheet For Each anySheet In ThisWorkbook.Worksheets If Not IsEmpty(anySheet.Range(keyCell)) Then anySheet.PrintOut copies:=1 End If Next End Sub "Brian" wrote: I have a workbook that has 24 tabs on it. It is used to evaluate people. An evaluator will evaluate up to 24 people. But not the max all the time. If thhey only do say 10, then I only want to print 10 from that workbook. The I might open 16 workbooks on an evaluation day and need to print only the worksheeets that have been typed onto. Is there a way to do an if command in a macro? |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
You're welcome, and thanks for the Thanks. It's nice to get that.
"Brian" wrote: That hit the nail on the head. With what I do at work I would pull my hair out if not for this website. Thanks for all you do MVP'ers "JLatham" wrote: Certainly it's possible. The key would be to determine one (or more) cell addresses that would be empty unless the sheet has been used to record an evaluation. The code below presumes 1 cell (A1) would meet that requirement. You can change that if required. To put the code into a workbook, open the workbook, press [Alt]+[F11] and then, from the Visual Basic Editor menu, choose Insert and Module and copy and paste (and modify) the code into it. Run the macro from Tools | Macro | Macros. This code prints each sheet individually, so they would all be numbered page 1 if you have page numbering set up in the header or footer. Sub PrintUsedSheets() Const keyCell = "A1" 'change to must be used cell address Dim anySheet As Worksheet For Each anySheet In ThisWorkbook.Worksheets If Not IsEmpty(anySheet.Range(keyCell)) Then anySheet.PrintOut copies:=1 End If Next End Sub "Brian" wrote: I have a workbook that has 24 tabs on it. It is used to evaluate people. An evaluator will evaluate up to 24 people. But not the max all the time. If thhey only do say 10, then I only want to print 10 from that workbook. The I might open 16 workbooks on an evaluation day and need to print only the worksheeets that have been typed onto. Is there a way to do an if command in a macro? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
print spreadsheets only if date has been typed onto it. | Excel Discussion (Misc queries) | |||
how do I print Just text I typed on top of a template | Excel Discussion (Misc queries) | |||
Macro to select and print sheets | Excel Discussion (Misc queries) | |||
Print Macro both sheets at once with option to select days etc | Excel Worksheet Functions | |||
Newbie seeks suggestion on recording new macro to print sheets | New Users to Excel |