Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
cdb cdb is offline
external usenet poster
 
Posts: 62
Default Set a range name

I am trying to set an area of a filter as a print area, and the way I am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the area
will be different everytime, so can someone please tell me how to do this?

cdb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Set a range name

See if this works. Apply this to where it sets the print area.

Range("A1:D" & range("D65536").end(xlup).row)

This will use the last row in column D with data in it.
HTH,
Paul

"cdb" wrote in message
...
I am trying to set an area of a filter as a print area, and the way I am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the
area
will be different everytime, so can someone please tell me how to do this?

cdb



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Set a range name

Post what you have so far and we will just tweak that...
--
HTH...

Jim Thomlinson


"cdb" wrote:

I am trying to set an area of a filter as a print area, and the way I am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the area
will be different everytime, so can someone please tell me how to do this?

cdb

  #4   Report Post  
Posted to microsoft.public.excel.programming
cdb cdb is offline
external usenet poster
 
Posts: 62
Default Set a range name

Here's what I have so far (it's not much):

Range("A4:T4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = PrintSelect
ActiveSheet.PageSetup.PrintArea = PrintSelect

cdb

"Jim Thomlinson" wrote:

Post what you have so far and we will just tweak that...
--
HTH...

Jim Thomlinson


"cdb" wrote:

I am trying to set an area of a filter as a print area, and the way I am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the area
will be different everytime, so can someone please tell me how to do this?

cdb

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Set a range name

Try this:

Range("A4:" & Range("T4").End(xlDown).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection


This may not work if there are blank cells between the data in column T.

You can try this as an alternative.

Range("A4:" & Range("T65536").End(xlUp).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection

Good luck.
Paul

"cdb" wrote in message
...
Here's what I have so far (it's not much):

Range("A4:T4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = PrintSelect
ActiveSheet.PageSetup.PrintArea = PrintSelect

cdb

"Jim Thomlinson" wrote:

Post what you have so far and we will just tweak that...
--
HTH...

Jim Thomlinson


"cdb" wrote:

I am trying to set an area of a filter as a print area, and the way I
am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the
area
will be different everytime, so can someone please tell me how to do
this?

cdb





  #6   Report Post  
Posted to microsoft.public.excel.programming
cdb cdb is offline
external usenet poster
 
Posts: 62
Default Set a range name

Neither of those work. I get an error message saying:

Run-time error '1004':

Unable to set the PrintArea property of the PageSetup class

cdb

"PCLIVE" wrote:

Try this:

Range("A4:" & Range("T4").End(xlDown).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection


This may not work if there are blank cells between the data in column T.

You can try this as an alternative.

Range("A4:" & Range("T65536").End(xlUp).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection

Good luck.
Paul

"cdb" wrote in message
...
Here's what I have so far (it's not much):

Range("A4:T4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = PrintSelect
ActiveSheet.PageSetup.PrintArea = PrintSelect

cdb

"Jim Thomlinson" wrote:

Post what you have so far and we will just tweak that...
--
HTH...

Jim Thomlinson


"cdb" wrote:

I am trying to set an area of a filter as a print area, and the way I
am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area, it
gives it specific cells (eg A1:D23). The problem with this is that the
area
will be different everytime, so can someone please tell me how to do
this?

cdb




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Set a range name

Try this code by itself. If it works fine, then it must be something in the
surrounding code causing it to fail at this point.

Sub test()
Range("A4:" & Range("T65536").End(xlUp).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection

End Sub



"cdb" wrote in message
...
Neither of those work. I get an error message saying:

Run-time error '1004':

Unable to set the PrintArea property of the PageSetup class

cdb

"PCLIVE" wrote:

Try this:

Range("A4:" & Range("T4").End(xlDown).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection


This may not work if there are blank cells between the data in column T.

You can try this as an alternative.

Range("A4:" & Range("T65536").End(xlUp).Address).Select
ActiveSheet.PageSetup.PrintArea = Selection

Good luck.
Paul

"cdb" wrote in message
...
Here's what I have so far (it's not much):

Range("A4:T4").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Name = PrintSelect
ActiveSheet.PageSetup.PrintArea = PrintSelect

cdb

"Jim Thomlinson" wrote:

Post what you have so far and we will just tweak that...
--
HTH...

Jim Thomlinson


"cdb" wrote:

I am trying to set an area of a filter as a print area, and the way
I
am
trying to do this is as follows:

Filter my results
Select the results
Give the selection a name
Set the named range as the print area

I tried recording a macro to do this, but when I set the print area,
it
gives it specific cells (eg A1:D23). The problem with this is that
the
area
will be different everytime, so can someone please tell me how to do
this?

cdb






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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 12:37 AM.

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"