+ Reply to Thread
Results 1 to 14 of 14

Setting print area based on input

  1. #1
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Setting print area based on input

    Hello,

    I am trying to automate filling out and printing various forms to save time. Right now I am having trouble with the attached form. This form dynamically updates based on how many mixes we are making of a certain product. The way we currently have to print this form is to select the cells we want to print and use print selection. This takes time and ruins an almost completely automated process that I have worked hard to make. I have tried using the following code to set the print area but it only works for the repeating top four rows.

    Please Login or Register  to view this content.
    The result is shown in the attached picture called wrong. The correct way it should come out for 2 mixes is attached called right.

    But I know that with each new mix added is 3 more rows and the minimum number of mixes of 1 I should be able to just have a linear scaling expression that adds 3 more rows per mix.

    I want the minimum print area to be A1:M7 and the max to be A1:M181 but max doesn't matter I can make it as long as we need. If we were making two mixes the print area would be A1:M10 and three would be A1:M13.

    What expression do I need that will make this happen? I think it would involve something like PrintArea("A1:M" & 7 + NumberofMixes * 3) but I do not know enough about VBA to make it work.


    The attached form is an example to show how the form updates but is not set up to print correctly aside from there being 7 mixes on each page with the repeating 4 rows at the top. It is supposed to be in landscape and set up to fill out the page beautifully but I thought it was not that important compared to decieding what to print .

    Thank you for your help,
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by QAChaska; 12-03-2013 at 11:54 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Setting print area based on input

    Can you not set printarea to be UsedRange?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    No idea. I have gotten this far from google and background of other programming languages. So far I have been able to skate by because I have been able to print the entire page not just a complete section. I would like to print the entire page but it has been eastablished that this form gets printed to the last filled out row instead of the complete page.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Setting print area based on input

    I don't see why the code you have doesn't work. How many rows do you have in column M?

    Isn't the default print area set to UsedRange? I would think the OP didn't want everything printed.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  5. #5
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    The code I used in the first post has the attached result labled wrong. The way I want the sheet to come out is attached right. The right attachment shows 2 mixes and no other empty cells below it.
    Attached Images Attached Images

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Setting print area based on input

    Can you attach your workbook as an example?

    To attach a workbook, click the 'Go Advanced' button below and use the paperclip in the toolbar to navigate to you document.

  7. #7
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    I can't attach the workbook I would be using but I made the example closer to what the real workbook is. The only differences are the footnotes and some individual cell heights.
    Attached Files Attached Files

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Setting print area based on input

    Column M doesn't have any values in it,
    Please Login or Register  to view this content.
    would return 4. What columns are completed when a new mix is added?

  9. #9
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    No new columns are added just rows. One mix is A1:M7, 2 is A1:M10, and 3 would be A1:M13. I don't know if that is the right terminology as the mix ends on a combined cell that starts in I. So for one mix the most right and downward cell that i would want to print would be I7 or A1:I7. Would I be able to change the code I have now to see if there is any information left in a cell that does have values in it? Like anything in the B or C colums?

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Setting print area based on input

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

  11. #11
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    I tried the code and it didn't work. As shown in the attached picture labled extra lines it doesn't just print the cells with information as the attached picture labled right does.

    Extralines.PNG


    right.PNG

  12. #12
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Setting print area based on input

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    Still no luck. I tried it replacing "E" with "C" and then "A" but neither of those worked either. If it helps any I am using

    Please Login or Register  to view this content.
    to verify that it will be printed correctly.

  14. #14
    Registered User
    Join Date
    11-12-2013
    Location
    Chaska, MN
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Setting print area based on input

    I figured it outwith Solus's Help.

    Please Login or Register  to view this content.
    Instead of trying to find out what cell was empty I was able to mess around enough with this format to set up a scaling expresion that stands up to every possible number.

    Thank you Solus and NathenSav

+ 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. Setting a print area in vba
    By harveywalker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 10:47 AM
  2. Setting Print Area based on Columns
    By ridonculous in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2012, 07:00 PM
  3. [SOLVED] setting up the print area
    By Gina in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2006, 01:15 PM
  4. Print Area:What would be the code for setting the print area
    By wammer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2005, 02:05 AM
  5. [SOLVED] Setting Print Area
    By Defoes Right Boot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2005, 08:06 AM

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