Forum Discussion

Ron_P88's avatar
Ron_P88
Copper Contributor
Aug 04, 2020

Set print range in VB macro

I need to set the print range within a VB for a table that has variable length from run to run. The table is made up of the sum of multiple subtotals, all of which change from run to tun. That only means that I don't know the last cell address until the table is assembles. How can I define the range for this variable size?

7 Replies

    • Ron_P88's avatar
      Ron_P88
      Copper Contributor

      Thank you for your continued support of my problem. I apologize for not responding sooner but other unrelated events have taken up my time. Your latest example looks promising and I will have to work with it to fit my case.

       

      Viele Dank!

       

      Ron

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Ron_P88 

    In VBA a simple print preview to build yourself. It can be set up as a module, as in the inserted workbook, or in any worksheet alone.
     
     
     

    If you find this helpful, please mark it as "Best Answer" and as Like (click thumbs up), it will be beneficial to more Community members reading here.

     

    Nikolino

    I know I don't know anything (Socrates)

    • Ron_P88's avatar
      Ron_P88
      Copper Contributor

      NikolinoDE 

       

      Sorry, but I don't see how this helps me. Perhaps I wasn't clear enough in describing my goal? I want to program the Set Print Range into my macro so I can print a variable range without human intervention. So far I have not found any way to use a variable to set the lower bound of the print range. The example in your post appears to have a fixed address in the print range specification (A1:AH60) although thi9s doesn't appear to be the range displayed when the Print Preview button is selected. What am I missing?

      • NikolinoDE's avatar
        NikolinoDE
        Platinum Contributor

        Ron_P88 

         

        Tailored to your area.

        If other area is desired or the whole worksheet it can be changed by VBA.

        Hope this worksheet meets your needs. If not please give a short feedback.
         

Resources