Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintArea

Status
Not open for further replies.

trefor

Technical User
Joined
Jun 22, 2003
Messages
3
Location
GB
I have a Spreadsheet (Excel 2000) which creats a table 8 columns wide by a variable number of rows (can be as small as 5 or 300-400)with the two top rqws being the table headers. The number of the last row is held in a separate cell. The table may have blank lines.

I need to be able to set the print area as part of a macro.
However the printarea code reqires (as far as I can make out)the range to be specified in terms such as $A$1:$H$76.
but how do I get to this if I know one addres as (say)$A$4 but the other only in terms of the column (8) and the row - a variable held in (say)square G8.
PrintArea = $A$1:Cells(myvariable,8)doesn't work neither does Printarea = $A$1:ActiveCell.Address - any ideas anyone?

 
Hi trefor,

PrintArea needs to be a string so, with your examples, use ..

Code:
"$A$1:" & Cells(myvariable,8).Address
or ...

Code:
"$A$1:" & ActiveCell.Address

Enjoy,
Tony
 
Tony,
Oh, I see. Didn't realise it had to be a string but would have struggled anyway! Many thanks for such a prompt and concise reply.Worked great. Again - many thanks
Trefor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top