Results 1 to 3 of 3

VBA Code to Print Only Visible Cells

This is a discussion on VBA Code to Print Only Visible Cells within the Excel Questions forums, part of the Question Forums category; I have a simple Macro that can print in both Landscape & Potrait but has to use custom views to ...

  1. #1
    New Member
    Join Date
    Jun 2012
    Posts
    9

    Default VBA Code to Print Only Visible Cells

    I have a simple Macro that can print in both Landscape & Potrait but has to use custom views to print. My spreadsheet has Subtotals in it and I'd like to print without the subtotals expanding which is currently happening. Can Anyone Assist? See my simple Macro below. Please Help.

    Sub CommandButton1_Click()
    ActiveWorkbook.CustomViews("custom print 1").Show
    ActiveWorkbook.PrintOut
    ActiveWorkbook.CustomViews("custom print 2").Show
    ActiveWorkbook.PrintOut
    MsgBox "Priting Complete"
    End Sub

    Thanks.

  2. #2
    Board Regular
    Join Date
    Dec 2007
    Location
    Oakhurst, New Jersey, USA
    Posts
    442

    Default Re: VBA Code to Print Only Visible Cells

    There is code to dictate what level of subtotals to display. Maybe this helps?


    ActiveSheet.Outline.ShowLevels RowLevels:=2

  3. #3
    New Member
    Join Date
    Jun 2012
    Posts
    9

    Default Re: VBA Code to Print Only Visible Cells

    Hi General Ledger,

    Thank you for the response.
    I tried to run it with that code and when I tried to print, it just printed them all. I'm fairly new tO VBA and was wondering if I'm doing it correctly? (see my vba code below)

    Sub CommandButton1_Click()
    ActiveWorkbook.CustomViews("custom print 1").Show
    ActiveWorkbook.PrintOut
    ActiveSheet.Outline.ShowLevels RowLevels:=3

    ActiveWorkbook.CustomViews("custom print 2").Show
    ActiveWorkbook.PrintOut
    ActiveSheet.Outline.ShowLevels RowLevels:=3
    MsgBox "Priting Complete"
    End Sub

    Thanks,

    Jasho

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com