Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define Name range Gotroots Excel Discussion (Misc queries) 10 December 19th 09 11:30 AM
Define a range jlclyde Excel Discussion (Misc queries) 2 April 17th 08 08:26 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM
Define a range globally Debbie[_7_] Excel Programming 2 December 24th 03 01:13 AM
Highlighting a Block of Cells to Define the Print Area Mark[_22_] Excel Programming 8 November 18th 03 03:43 AM


All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"