+ Reply to Thread
Results 1 to 6 of 6

VBA Define columns to print on Active sheets array

  1. #1
    Registered User
    Join Date
    06-02-2014
    Posts
    3

    VBA Define columns to print on Active sheets array

    Hi,

    I have the below macro to check all sheets on my Workbook that have data in cell 101 and print:

    Sub CHECKSHEET2()
    Dim Sh As Worksheet
    Dim Arr() As String
    Dim N As Integer
    N = 0
    For Each Sh In ActiveWorkbook.Worksheets
    If Sh.Visible = xlSheetVisible And Sh.Range("A101").Value <> "" Then
    N = N + 1
    ReDim Preserve Arr(1 To N)
    Arr(N) = Sh.Name
    End If
    Next
    With ActiveWorkbook
    .Worksheets(Arr).PrintOut
    End With
    End Sub

    Also, sometimes I need to send the printout to Adobe Acrobat (as one of the printers from the printer selection list on excel) to create a PDF file and currently if there is more than one active sheet to print, the Macro saves the printout as one file with separate pages rather than several individual PDF files (the latter of which is not what I want as there could be a lot of pages!).

    I would also like to tell the Macro to not print out columns C to E and M as this data is not necessary for the print outs, but I'm not sure how to do this without losing any of the macro's functionality.

    Any help would be greatly appreciated.

    Thanks WORKSHEET-TEST-.xls

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Define columns to print on Active sheets array

    Hi folksteve

    Welcome to the Forum!!

    Please use Code Tags around any Code you post.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    This Code will hide the Columns you indicated
    Please Login or Register  to view this content.
    Regarding the PDF question, what version of Excel are you using?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    06-02-2014
    Posts
    3

    Re: VBA Define columns to print on Active sheets array

    Hi John, thanks for the response and advice on how to post code (I always wondered how that was done)

    I'm away from my computer so will try out the new code when I next get the chance.

    In response to your question I'm using excel 2007 on windows 7

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Define columns to print on Active sheets array

    Hi Steve

    I asked about your Excel Version because you posted an .xls File. Does the Code need to accommodate pre Excel 2007?

  5. #5
    Registered User
    Join Date
    06-02-2014
    Posts
    3

    Re: VBA Define columns to print on Active sheets array

    Not really. It was first created in 2003 then we upgraded to 2007

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: VBA Define columns to print on Active sheets array

    Hi Steve

    Try these two Code snippets.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. print sheets BY array values
    By petix in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-29-2013, 06:51 AM
  2. Code to print columns with active rows not working
    By debbiesh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2009, 05:14 PM
  3. [SOLVED] Print Array for hidden sheets using VBA
    By Ant in forum Excel General
    Replies: 1
    Last Post: 03-27-2006, 06:24 AM
  4. [SOLVED] Print Array for hidden sheets using VBA
    By Ant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2006, 04:30 AM
  5. [SOLVED] Define array of sheets by inputbox
    By Herman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2005, 11:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1