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


If I wanted to set the print area to just print
Sheets("Sheet1").Range("A1":"E9")
rather than the whole sheet, how do I do this from a macro button. I
know that
ActiveSheet.Printout prints the whole sheet, but I need to set the
print area 1st.
The print area will be variable depending on what I decide to import
into the active sheet.


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=515670

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Print area

grahammal,
Try:
With ActiveSheet
.PageSetup.PrintArea = .UsedRange.Address
End With

NickHK

"grahammal" wrote
in message ...

If I wanted to set the print area to just print
Sheets("Sheet1").Range("A1":"E9")
rather than the whole sheet, how do I do this from a macro button. I
know that
ActiveSheet.Printout prints the whole sheet, but I need to set the
print area 1st.
The print area will be variable depending on what I decide to import
into the active sheet.


--
grahammal
------------------------------------------------------------------------
grahammal's Profile:

http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=515670



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


Sheets("Sheet1").Range("A4":"A8")

Sub Button1_Click()
With ActiveSheet
PageSetup.PrintArea = .UsedRange.Address
End With
End Sub

What do I need to substitute with what for the above to work?
I assume that either the 'UsedRange' or the 'Address' part has to be
substituted with something for that to work.


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=515670

  #4   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Print area

..UsedRange is a worksheet property that includes all cells on a sheet that
have data.

..Address is the absolute reference from the first cell in the upper left
corner, to the last cell in the lower right corner, of .UsedRange.

That means everything on the sheet will print!

If you can live with doing what you want manually, then select the cells to
print and specify "Selection" in the print dialog's "Print what" section.
Otherwise, you'll have to define the imported data as a named range and refer
to it in code.

Regards,
GS

"grahammal" wrote:


Sheets("Sheet1").Range("A4":"A8")

Sub Button1_Click()
With ActiveSheet
.PageSetup.PrintArea = .UsedRange.Address
End With
End Sub

What do I need to substitute with what for the above to work?
I assume that either the 'UsedRange' or the 'Address' part has to be
substituted with something for that to work.


--
grahammal
------------------------------------------------------------------------
grahammal's Profile: http://www.excelforum.com/member.php...o&userid=20336
View this thread: http://www.excelforum.com/showthread...hreadid=515670


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
Macro - Set Print Area for Changing Data Area ksp Excel Programming 5 May 15th 06 10:20 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 05:15 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"