Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to define a print range?
I have a worksheet that a user enters data starting at "A7". For each input row he fills columns "A" thru "G". He then presses a commandbutton to calculate columns "I" thru "N" for each entry. I clear the area A7:BB500, knowing there won't be more than 150 rows at any one time. Now I'm planning to provide a commandbutton to print the keyed-in data and calculated results. If the user only enters say 15 rows of data, does the calculation and goes to print. It prints many blank pages after the data. I'm assuming the print settings say to print thru range BB500 or at least BBxx. (xx=last row) How do I get only the entire range of data entered/calced (a7:n22) to be printed? Please show in code. Starting range is "A7". Ending row is retrieved using "xlup". I know last column to be printed is "N". Dim StartRange as Range Dim LastRow as Long Dim LastCol as String LastCol = "N" Set StartRange = Range("A7") LastRow = ActiveSheet.Cells(65535, 3).End(xlUp).Row Now, how do I assemble all this information and place into the print area range????? tt |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to define a print range?
The following will probably solve your problem without any need
to set the print area. Usually if you have to set the print area you have something wrong. dim xlong as long xlong = ActiveSheet.UsedRange.Rows.Count 'correct lastcell More information in Automatically Resetting the Last Cell in Excel 97, Tip 73, John Walkenbach. Activesheet.UsedRange has also been suggested. http://www.j-walk.com/ss/excel/tips/tip73.htm Reset Last Used Cell http://www.mvps.org/dmcritchie/excel/lastcell.htm look in Excel VBA help for printarea -- --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "TinyTim" wrote in message ... I have a worksheet that a user enters data starting at "A7". For each input row he fills columns "A" thru "G". He then presses a commandbutton to calculate columns "I" thru "N" for each entry. I clear the area A7:BB500, knowing there won't be more than 150 rows at any one time. Now I'm planning to provide a commandbutton to print the keyed-in data and calculated results. If the user only enters say 15 rows of data, does the calculation and goes to print. It prints many blank pages after the data. I'm assuming the print settings say to print thru range BB500 or at least BBxx. (xx=last row) How do I get only the entire range of data entered/calced (a7:n22) to be printed? Please show in code. Starting range is "A7". Ending row is retrieved using "xlup". I know last column to be printed is "N". Dim StartRange as Range Dim LastRow as Long Dim LastCol as String LastCol = "N" Set StartRange = Range("A7") LastRow = ActiveSheet.Cells(65535, 3).End(xlUp).Row Now, how do I assemble all this information and place into the print area range????? tt |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Define Name range | Excel Discussion (Misc queries) | |||
Define a range | Excel Discussion (Misc queries) | |||
Define a range based on another named range | Excel Worksheet Functions | |||
Define a range globally | Excel Programming | |||
Highlighting a Block of Cells to Define the Print Area | Excel Programming |