Results 1 to 4 of 4

Thread: Limit Cells That Are To Be Printed Or Exported To PDF Document Or Hide Columns

  1. #1
    Member
    Join Date
    Jun 2013
    Posts
    52
    Rep Power
    11

    Question Limit Cells That Are To Be Printed Or Exported To PDF Document Or Hide Columns

    Ok here is the problem I have run into. I have a code on the page to limit the printing area to a certain amount of cells, but I'm finding that the code does nothing if it is exported to or converted to a .pdf document. There are several columns I am using for VBA coding information that do not need to be printed or displayed. Example of these columns would by J,k and L. J is being used for calculations and simply displays a text value. This column is then searched for a certain text phrase and it is counted and displayed on another sheet. K is simply a column that ranges from the #1 to 20000. This column was created to give a unique value to each row. This was per another user and so far everything has worked fine.

    The problem is that if I "HIDE" the column the VBA code seems to crash because it needs to be able to see that code on the sheet to work. If I leave the codes on there and export or convert to a .PDF file it also takes those pages and now instead of a 50 page file it is 1000's of pages long. It keeps printing all the column "K" values. This is useless as in most inspections will not have that many numbers. I just made it so that any amount of devices could be added by the user or copied and pasted into the workbook.

    I'm looking for a way to solve the problem of having these columns printed or converted to a .PDF file. If it is as simple as having the VBA code work from a hidden column that is fine. The idea is that I just want to print the information from columns A - I.

    As it is the inspectors can not figure out how to get just the information they need.


    Thanks for any help you can give.

    I'm sorry for the explanation but I really don't know how to explain it any better.

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837
    https://www.eileenslounge.com/viewtopic.php?f=21&t=40701&p=314836#p314836
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314621#p314621
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314619#p314619
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314600#p314600
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314599#p314599
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314274#p314274
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314229#p314229
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314195#p314195
    https://www.eileenslounge.com/viewtopic.php?f=36&t=39706&p=314110#p314110
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314081#p314081
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314078#p314078
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314062#p314062
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314054#p314054
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313971#p313971
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313909#p313909
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40574&p=313879#p313879
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 02-29-2024 at 09:45 PM.

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    If you want to print it, you can manually set the print area from A to I

    But if you want to create a PDF, you could use a macro that hides the unwanted columns, and then conver to PDF, and then unhide the columns back to the original state.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Member
    Join Date
    Jun 2013
    Posts
    52
    Rep Power
    11
    Would it be possible to explain this a little more? I'm thinking the macro would be a better idea. And just have it run manually before it is exported to .pdf

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837
    https://www.eileenslounge.com/viewtopic.php?f=21&t=40701&p=314836#p314836
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314621#p314621
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314619#p314619
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314600#p314600
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314599#p314599
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314274#p314274
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314229#p314229
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40621&p=314195#p314195
    https://www.eileenslounge.com/viewtopic.php?f=36&t=39706&p=314110#p314110
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314081#p314081
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314078#p314078
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314062#p314062
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40597&p=314054#p314054
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313971#p313971
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313909#p313909
    https://www.eileenslounge.com/viewtopic.php?f=27&t=40574&p=313879#p313879
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313859#p313859
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313855#p313855
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313848#p313848
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313843#p313843
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313792#p313792
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313771#p313771
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313767#p313767
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313746#p313746
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313744#p313744
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40560&p=313741#p313741
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313622#p313622
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313575#p313575
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313573#p313573
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313563#p313563
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=313555#p313555
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40533
    https://www.eileenslounge.com/viewtopic.php?f=39&t=40265&p=313468#p313468
    https://www.eileenslounge.com/viewtopic.php?f=42&t=40505&p=313411#p313411
    https://www.eileenslounge.com/viewtopic.php?f=32&t=40473&p=313384#p313384
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313382#p313382
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313380#p313380
    https://www.eileenslounge.com/viewtopic.php?f=30&t=40501&p=313378#p313378
    https://www.eileenslounge.com/viewtopic.php?f=32&t=40473&p=313305#p313305
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40455&p=313035#p313035
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312889#p312889
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312886#p312886
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312752#p312752
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312734#p312734
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312727#p312727
    https://www.eileenslounge.com/viewtopic.php?f=18&t=40411&p=312724#p312724
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40374&p=312535#p312535
    https://www.eileenslounge.com/viewtopic.php?p=312533#p312533
    https://www.eileenslounge.com/viewtopic.php?f=44&t=40373&p=312499#p312499
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 02-29-2024 at 09:33 PM.

  4. #4
    Moderator
    Join Date
    Jul 2012
    Posts
    156
    Rep Power
    12
    As I stated in my last reply to your other thread, set a Printarea and in the ExportAsFixedFormat-method set the IgnorePrintAreas-property to False.
    For ex.
    Code:
    Sub ExportPdf()
    
        Const PdfPath = "D:\My documents\"
        Const PdfName = "Inspector"
        With Sheets("INITIATING DEVICES")
            .PageSetup.PrintArea = .Range("A1:I" & .Cells(Rows.Count, 4).End(xlUp).Row).Address
            .ExportAsFixedFormat xlTypePDF, PdfPath & PdfName & ".pdf", _
                    0, False, False, , , True
        End With
        
    End Sub
    The PrintArea is now set to the Entire A-I range but you could make this dynamic by using Application.InputBox so you can define the PrintArea manually, or use AutoFilter to extract certain information and with SpecialCells export the Visible cells only.

Similar Threads

  1. Replies: 3
    Last Post: 05-23-2013, 11:17 PM
  2. Excel Macro Functions (GET.DOCUMENT)
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 2
    Last Post: 06-29-2011, 08:10 PM
  3. Hide/Unhide Columns with Listbox
    By obed_cruz in forum Excel Help
    Replies: 2
    Last Post: 05-28-2011, 07:26 PM
  4. Hide and Unhide Rows and Columns
    By Admin in forum Download Center
    Replies: 0
    Last Post: 05-11-2011, 12:00 AM
  5. Replies: 4
    Last Post: 04-07-2011, 07:09 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •