Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Set Print Area programatically

Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Set Print Area programatically

Hi Mervyn

Use this
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(NoOfRows, 29)).Address

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mervyn Thomas" wrote in message ...
Can anyone help me get the syntax right. I have tried variations on the theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Set Print Area programatically

Syntax is OK; are you sure NoOfRows gives the correct result? If it is 0,
this would give "Application defined or object defined error."

"Mervyn Thomas" wrote:

Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Set Print Area programatically

Thanks - that works!
"Ron de Bruin" wrote in message
...
Hi Mervyn

Use this
ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(NoOfRows,
29)).Address

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mervyn Thomas" wrote in message
...
Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Set Print Area programatically

I thought so too! but the other reply does work
Mervyn
"K Dales" wrote in message
...
Syntax is OK; are you sure NoOfRows gives the correct result? If it is 0,
this would give "Application defined or object defined error."

"Mervyn Thomas" wrote:

Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Set Print Area programatically

It miss
..Address after selection

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Mervyn Thomas" wrote in message ...
I thought so too! but the other reply does work
Mervyn
"K Dales" wrote in message ...
Syntax is OK; are you sure NoOfRows gives the correct result? If it is 0,
this would give "Application defined or object defined error."

"Mervyn Thomas" wrote:

Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Set Print Area programatically

PrintArea requires a string argument. It resists range objects unless they
contain a string address

maybe selection.Address

--
Regards,
Tom Ogilvy



"K Dales" wrote in message
...
Syntax is OK; are you sure NoOfRows gives the correct result? If it is 0,
this would give "Application defined or object defined error."

"Mervyn Thomas" wrote:

Can anyone help me get the syntax right. I have tried variations on the
theme:

Range(Cells(1, 1), Cells(NoOfRows, 29)).Select
ActiveSheet.PageSetup.PrintArea = Selection

but cannot get anything past the debugger!

Thanks
mervyn





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
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
File, print area, clear area, is not working cblind New Users to Excel 2 September 12th 07 04:51 PM
print area across the freeze panes area tom Excel Worksheet Functions 2 January 6th 07 05:23 PM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
How do you turn off a print area for a page? (no print area) Grunen Excel Discussion (Misc queries) 4 October 8th 05 07:46 PM


All times are GMT +1. The time now is 02:34 PM.

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

About Us

"It's about Microsoft Excel"