Results 1 to 4 of 4

Thread: Printing pages in Excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4

    Printing pages in Excel

    This one's more Excel's than VBA, but let's see if anyone's here can help me.

    On a Worksheet, I want to print columns 1,2 and 3 (A,B and C) side to side with columns 15,16 and 17 (O,P and Q). I can freeze a pane that includes column 1,2 and 3, or I can use the vertical division box that fits well for working. But when it comes to print, the print preview separates it in 2 different pages.

    How can I print it in a single page? Perhaps it's very simple, but It's the first time I need to do this and I can't figure it out.

    Thank's in advance

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    You will probably need some version of this to set the print area
    to what you want.

    VB Code:
    1. Worksheets("Sheet1").PageSetup.PrintArea = "$A$1:$C$10"
    And this will be to clear the print area and make it the whole sheet.
    VB Code:
    1. Worksheets("Sheet1").PageSetup.PrintArea = ""
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    4
    Right. But is there another way of working with x,y (user choosen) rather than fixed numbers r1c1?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    What version of Excel are you using? In 2003 you can use the
    menu item File > Print Area > Set Print Area
    This is the user choosen method.

    Or you can program it in a column range allowing the user to
    enter the columns or even allow them to enter a range. Just
    make sure that if you want columns that are not contiguous then
    add a comma between the ranges.

    VB Code:
    1. Public Sub PrintMe()
    2.     Worksheets("Sheet1").PageSetup.PrintArea = "$A:$C[color=red],[/color]$O:$Q"
    3. End Sub
    If you want to prompt the user instead of using the set print area
    menu item, then use an inputbox and set the area to a range
    variable.

    HTH


    VB/Outlook Guru!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width