Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 683
Default macro to print sheets from wrkbk only if data has been typed in

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default macro to print sheets from wrkbk only if data has been typed in

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 683
Default macro to print sheets from wrkbk only if data has been typed i

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default macro to print sheets from wrkbk only if data has been typed i

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
print spreadsheets only if date has been typed onto it. Brian Excel Discussion (Misc queries) 1 February 15th 08 07:47 PM
how do I print Just text I typed on top of a template Rudy Excel Discussion (Misc queries) 1 October 23rd 07 02:03 PM
Macro to select and print sheets JoeP Excel Discussion (Misc queries) 3 April 19th 07 06:44 PM
Print Macro both sheets at once with option to select days etc pano Excel Worksheet Functions 0 January 29th 07 04:09 AM
Newbie seeks suggestion on recording new macro to print sheets Vivian New Users to Excel 2 May 10th 06 06:53 AM


All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"