Solved

Excel worksheets consolidated for printing

Posted on 2011-03-16
3
321 Views
Last Modified: 2012-05-11
I'm creating a punch list in excel with each worksheet representing a different room in an apartment. When finished  I would like to do is create pdf of the consolidated worksheets. But I would also like that consolidation to be only the worksheets that contain entries in the punch list items column that exists on each worksheet. I'm trying to avoid a pdf that contains empty worksheets.
 Would it be easier to have a button that would allow me to select which sheets I want? Could the code run through each worksheet for a specific range, and if the cells in that range contain any data, add that worksheet to the pdf? I have a couple of driver options for printing to pdf.
0
Comment
Question by:wlamore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 19

Expert Comment

by:akoster
ID: 35149237
printing to pdf is best done using a regular "print-to-pdf" driver, any will do.

Easiest way to do this is to browse through all worksheets, determine for each one wether or not it is to be printed, and then print them out.
This is not a very difficult thing to do in a macro !
Best way would be to assign this macro to a key combination so that you can start the macro just by pressing some keys.
0
 
LVL 19

Accepted Solution

by:
akoster earned 250 total points
ID: 35149345
Public Sub print_to_pdf()

Dim ws As Worksheet
Dim to_be_printed()

    ReDim to_be_printed(1)
    
    '-- loop through worksheets
    For Each ws In Worksheets
    
        '-- if more than 1 rows are used, worksheet is considered filled with data
        If ws.UsedRange.Rows.Count > 1 Then
            ReDim Preserve to_be_printed(UBound(to_be_printed) + 1)
            to_be_printed(UBound(to_be_printed) - 1) = ws.Name
        End If
    
    Next ws
    ReDim Preserve to_be_printed(UBound(to_be_printed) - 1)
    
    '-- print out the sheets that need to be printed
    sheets(to_be_printed).PrintOut
    
End Sub

Open in new window

0
 
LVL 19

Expert Comment

by:akoster
ID: 35149356
Best would be to also add
option base 1

Open in new window


as the first line of the module containing the macro
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question