Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Changing Print area

I have a spreadsheet and I want the macro to set the print
area for me each time since the amount of data will be
chaning on a regular basis. I have the following from
using the macro recorder but it is not working. The macro
recorder hardcoded the cell addresses based on the current
data. I'm trying to change it to change the print area to
the selected cells. Any suggestions would be
appreciated. Here's the code I tried:

Sub Print_Area()

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select

(The above lines properly select the data I want. The
following line is where I have the problem. I just don't
know the proper syntax.)

ActiveSheet.PageSetup.PrintArea = Selection

End Sub

Thanks for the help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Changing Print area

Try:

ActiveSheet.PageSetup.PrintArea = Selection.Address

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"JT" wrote in message
...
I have a spreadsheet and I want the macro to set the print
area for me each time since the amount of data will be
chaning on a regular basis. I have the following from
using the macro recorder but it is not working. The macro
recorder hardcoded the cell addresses based on the current
data. I'm trying to change it to change the print area to
the selected cells. Any suggestions would be
appreciated. Here's the code I tried:

Sub Print_Area()

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select

(The above lines properly select the data I want. The
following line is where I have the problem. I just don't
know the proper syntax.)

ActiveSheet.PageSetup.PrintArea = Selection

End Sub

Thanks for the help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Changing Print area

Bob, perhaps you can help. I tried to use the code below but it does not
select the area I want to print.

I need to print from cell A1 to (and including) the last row of data. I
have additional rows of formatting after that but I do not want to print
those.

Orf Bartrop

Bob Flanagan wrote:

Try:

ActiveSheet.PageSetup.PrintArea = Selection.Address

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"JT" wrote in message
...


I have a spreadsheet and I want the macro to set the print
area for me each time since the amount of data will be
chaning on a regular basis. I have the following from
using the macro recorder but it is not working. The macro
recorder hardcoded the cell addresses based on the current
data. I'm trying to change it to change the print area to
the selected cells. Any suggestions would be
appreciated. Here's the code I tried:

Sub Print_Area()

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select

(The above lines properly select the data I want. The
following line is where I have the problem. I just don't
know the proper syntax.)

ActiveSheet.PageSetup.PrintArea = Selection

End Sub

Thanks for the help.








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
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
changing print area in an entire workbook lschuh Excel Worksheet Functions 7 August 4th 05 02:52 PM
Changing print area Aaron Excel Discussion (Misc queries) 2 January 9th 05 05:58 PM


All times are GMT +1. The time now is 10:25 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"