![]() |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 05:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com