Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how do I print a named dynamic range

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default how do I print a named dynamic range

Add the following code to the ThisWorkbook module in your project (Right
click the Excel icon next to the word file in the menu bar and select View
Code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").PageSetup.PrintArea = Sheet1.Range("DynaRange").Address
End Sub
--
HTH...

Jim Thomlinson


"Rock_on_Richard" wrote:

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default how do I print a named dynamic range

Sorry should be...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
with Sheets("Sheet1")
.PageSetup.PrintArea = .Range("DynaRange").Address
end with
End Sub

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the following code to the ThisWorkbook module in your project (Right
click the Excel icon next to the word file in the menu bar and select View
Code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").PageSetup.PrintArea = Sheet1.Range("DynaRange").Address
End Sub
--
HTH...

Jim Thomlinson


"Rock_on_Richard" wrote:

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do I print a named dynamic range

Jim,
Thanks for the suggestion. I entered ran your code and got a runtime error
'9': subscript out of range message. Do you have any further suggestions
please?
Thanks

"Jim Thomlinson" wrote:

Sorry should be...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
with Sheets("Sheet1")
.PageSetup.PrintArea = .Range("DynaRange").Address
end with
End Sub

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the following code to the ThisWorkbook module in your project (Right
click the Excel icon next to the word file in the menu bar and select View
Code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").PageSetup.PrintArea = Sheet1.Range("DynaRange").Address
End Sub
--
HTH...

Jim Thomlinson


"Rock_on_Richard" wrote:

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default how do I print a named dynamic range

Change this line:

with Sheets("Sheet1")

to match the name of the worksheet.

with Sheets("YourSheetNameGoesHere")

Rock_on_Richard wrote:

Jim,
Thanks for the suggestion. I entered ran your code and got a runtime error
'9': subscript out of range message. Do you have any further suggestions
please?
Thanks

"Jim Thomlinson" wrote:

Sorry should be...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
with Sheets("Sheet1")
.PageSetup.PrintArea = .Range("DynaRange").Address
end with
End Sub

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the following code to the ThisWorkbook module in your project (Right
click the Excel icon next to the word file in the menu bar and select View
Code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").PageSetup.PrintArea = Sheet1.Range("DynaRange").Address
End Sub
--
HTH...

Jim Thomlinson


"Rock_on_Richard" wrote:

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default how do I print a named dynamic range

Thanks for the wonderful help. I'm getting closer to a solution.

This works great until I close and reopen the file. Then it acts like the
code is not there at all. To get it to work again I have to delete all of
the code, save and close the file, close Excel, them reopen the file and
reenter the code. What do you think is going on and how do I fix this little
problem.

Thanks again,

"Dave Peterson" wrote:

Change this line:

with Sheets("Sheet1")

to match the name of the worksheet.

with Sheets("YourSheetNameGoesHere")

Rock_on_Richard wrote:

Jim,
Thanks for the suggestion. I entered ran your code and got a runtime error
'9': subscript out of range message. Do you have any further suggestions
please?
Thanks

"Jim Thomlinson" wrote:

Sorry should be...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
with Sheets("Sheet1")
.PageSetup.PrintArea = .Range("DynaRange").Address
end with
End Sub

--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Add the following code to the ThisWorkbook module in your project (Right
click the Excel icon next to the word file in the menu bar and select View
Code)...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Sheets("Sheet1").PageSetup.PrintArea = Sheet1.Range("DynaRange").Address
End Sub
--
HTH...

Jim Thomlinson


"Rock_on_Richard" wrote:

I am not sure if this question should go to this group, the worksheet
functions group, or the general questions group. Please redirect the
question if I have chosen the wrong group.

I want to print a named dynamic range so that the print area changes as the
dynamic range changes. The named dynamic range is easy enough to set up
using the count function nested within the offset function in the name
definition. When I used the range name in the print area field on the print
setup page the correct area is calculated and printed the first time a print
command is issued but the range name is replaced with the calculated range
values and the range is frozen, not dynamic after that first printing. How
do prevent this from happening so that each time I print it goes out and
calculates a new range.

I am using Office 2003 SP2

Thanks


--

Dave Peterson

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
dynamic named range Gadeyne Dries New Users to Excel 3 April 4th 10 05:28 AM
Dynamic Named Range dhstein Excel Discussion (Misc queries) 4 October 11th 09 11:15 PM
Dynamic Named Range Madiya Excel Programming 7 August 14th 06 02:19 PM
getting the absolute range address from a dynamic named range junoon Excel Programming 2 March 21st 06 01:29 PM
dynamic named range Steph[_3_] Excel Programming 3 March 22nd 05 02:56 PM


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