+ Reply to Thread
Results 1 to 5 of 5

Print preview range with margins

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Print preview range with margins

    Hi,

    When sample workbook is populated there will be date in columns A:G, I want to print a report that doesn't include irrelevant cells so would like to print range A7:G lastrow when the Print Report button is clicked.

    Currently I have this code that goes to print preview with the right range selected but when I close preview an error occurs saying that its a formula that starts with =/-

    Please Login or Register  to view this content.
    Basically looking for code that will print preview A7;G lastrow with narrow margins

    When I try recording a macro it comes back with

    Please Login or Register  to view this content.
    Anyone got any ideas please.

    Down the line I would probably change print preview to direct printing if the right settings are default.

    Thanks
    Attached Files Attached Files
    Last edited by ~TaC~; 12-08-2020 at 06:17 PM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Print preview range with margins

    .
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Thanks, almost right result. this limits column G to row 345 where in OP I said I would like to print A7:G & lastrow (I forgot the &)

  4. #4
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Thought I fixed it but haven't.

    Changed code to:

    Please Login or Register  to view this content.
    incorporating my original range code, previews the right data but when closing print preview shows following error

    Run-time error '1001:

    There's a problem with this formula.

    Not trying to type a formula?
    When the first character is an equal ("=") or minus ("-") sign, Excel
    thinks its a formula:
    •you type: =1+1. cell shows: 2

  5. #5
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    Re: Print preview range with margins

    Think I fixed it with this code

    Please Login or Register  to view this content.
    Print previews required columns to last row with narrow margins so all nearly good however when I close the print preview box the system goes to 'not responding' for a few seconds and then recovers. Is this normal or error in code?

+ 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 preview margins don't match printout
    By boborr in forum Excel General
    Replies: 0
    Last Post: 03-05-2013, 01:56 PM
  2. macro to adjust print margins in print preview mode
    By yeoye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2009, 06:16 AM

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