+ Reply to Thread
Results 1 to 20 of 20

How to highlight dynamic print area?

  1. #1
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    How to highlight dynamic print area?

    The code below highlight the dynamic print area of page 2 (by another VBA):

    Please Login or Register  to view this content.
    where the top and below row can be determined by page break;
    but the left and right column has to be set manually after dynamic print area is set.
    e.g. ".Resize(, 11)"

    How to revise the VBA to highlight dynamic print area (of page 2 only)?
    (i.e. determining the left and right column by VBA)

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    Use:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    PS. If the first page do not start from column 1 (because of setup of print area) try:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Hi Kaper,

    The VBA works if print area start from Column A.

    If start from Column B, there is error message (translated from my Chinese Excel):
    Execution error no. 9
    Index of column/row out of range

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    Error occurs while using code from post #3 or #4?
    If it's always column B use:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Hi Kaper ,

    There is same execution error 9 - Index of column/row out of range.

    But if the print range is extended to Column A (from B),
    then Column B to right of page break is highlighted.

    (it is not my expectation as highlighted area not match printed area and I don't want to print column A)

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    please attach small sample workbook

  8. #8
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Hi Kaper,

    I can't attach the excel file as the file (only 185KB) cannot be uploaded.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,981

    Re: How to highlight dynamic print area?

    That file is not too big - why can't it be uploaded?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Upon my log out and then log in, please see the excel.
    Attached Files Attached Files

  11. #11
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    If there is no Vertical page breaks and last column is always M then:
    Please Login or Register  to view this content.
    Shall do the job

  12. #12
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Hi Kaper,

    I want the page to be set by HPageBreak and VPageBreak as the print range of each page may be changed.

  13. #13
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: How to highlight dynamic print area?

    Will you please attach a SMALL sample Excel workbook(s) (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. (If trere are typical cases like: all unique values/duplicates could occur, day/night, nobody present/several persons at once, before/on/past due, etc. - please show them all or at least indicate in text) The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution(s) is/are also shown (mock up the results manually).

    3. Make sure that all confidential/restricted information (either personal or business) like real e-mails, social security numbers, bank accounts, etc. is removed first!!

    To attach an Excel file you have to do the following: Just before posting, scroll down and press Go Advanced button and then scroll down and press Manage Attachments link. Now follow the instructions at the top of that pop-up screen.

  14. #14
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Please see attached excel file that print range need to be highlighted by VBA.
    Attached Files Attached Files

  15. #15
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: How to highlight dynamic print area?

    Sub zz()
    Range("print_area").Select
    End Sub
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    How to highlight page 2 only?

  17. #17
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: How to highlight dynamic print area?

    try this:
    Please Login or Register  to view this content.
    Last edited by ikboy; 10-30-2017 at 11:23 PM.

  18. #18
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Hi ikboy,

    It's works for page 2 only.

    How to revise VBA so that:
    1. InputBox("Page(s) for highlight", , "1,3,5-6")
    2. The input pages (e.g. 1,3) will be highlighted.

  19. #19
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: How to highlight dynamic print area?

    Please post new thread for new.

  20. #20
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to highlight dynamic print area?

    Thanks ikboy and Kaper.

+ 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. [SOLVED] Set print area for a dynamic range and launch print dialog
    By BONCH in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-17-2017, 11:37 PM
  2. Dynamic Print Area Reset by Print Preview
    By dhpeter83 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-24-2015, 04:17 PM
  3. how to print using combobox and make dynamic range of a print area
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-04-2014, 07:26 AM
  4. Code and Formula to print dynamic print area ranges
    By stpeter in forum Excel General
    Replies: 1
    Last Post: 10-15-2013, 03:33 PM
  5. Replies: 1
    Last Post: 09-05-2013, 03:32 AM
  6. [SOLVED] Need ‘Set Print Area’ Code for Dynamic Print Range based on Conditions
    By dosbirn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2013, 12:13 PM
  7. Replies: 2
    Last Post: 01-04-2013, 04:22 PM

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