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

Sorry, forgot to enter the subject,

Hi,
I'm using a Combobox from the Forms toolbar to select print ranges via a
macro, the link cell for the Combobox being named "mon". What I have at the
moment is:-

If Range("mon").Value = 1 Then ActiveSheet.PageSetup.PrintArea =
"$B$1:$AC$54"
If Range("mon").Value = 2 Then ActiveSheet.PageSetup.PrintArea =
"$AD$1:$BE$54"
If Range("mon").Value = 3 Then ActiveSheet.PageSetup.PrintArea =
"$BF$1:$CG$54"

and so on.
I want to do something like (I know this is wrong because it doesn't work!)

ActiveSheet.PageSetup.PrintArea = Range([Whatever])

so that I can use a VLOOKUP using "mon" as the first argument in the
worksheet to put the required range in "Whatever" and use just one line of
code instead of 15 as I have at the moment.

I'm sure it can be done but I cant work out how. Can anyone please advise
me?
Hope I'm making sense,
Many thanks,
Regards,
Alan.

XL2002
WIN XP Professional


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Ranges

Assume you have your print area addresses in the range A11:A25 on Sheet3

Dim sStr as String, sName as String
sStr = Worksheets("Sheet3").Range("A11:A25") _
.Offset(Range("Mon").Value-1,0).Value
sName = "'" & Activesheet.Name & "'!"
Activesheet.PageSetup.PrintArea = sName & sStr

--
Regards,
Tom Ogilvy


Alan wrote in message
...
Sorry, forgot to enter the subject,

Hi,
I'm using a Combobox from the Forms toolbar to select print ranges via

a
macro, the link cell for the Combobox being named "mon". What I have at

the
moment is:-

If Range("mon").Value = 1 Then ActiveSheet.PageSetup.PrintArea =
"$B$1:$AC$54"
If Range("mon").Value = 2 Then ActiveSheet.PageSetup.PrintArea =
"$AD$1:$BE$54"
If Range("mon").Value = 3 Then ActiveSheet.PageSetup.PrintArea =
"$BF$1:$CG$54"

and so on.
I want to do something like (I know this is wrong because it doesn't

work!)

ActiveSheet.PageSetup.PrintArea = Range([Whatever])

so that I can use a VLOOKUP using "mon" as the first argument in the
worksheet to put the required range in "Whatever" and use just one line of
code instead of 15 as I have at the moment.

I'm sure it can be done but I cant work out how. Can anyone please advise
me?
Hope I'm making sense,
Many thanks,
Regards,
Alan.

XL2002
WIN XP Professional




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

Name your print ranges "page1", "page2", etc. then use this code:

Sub PrntRng()
ActiveSheet.PageSetup.PrintArea = "page" & Range("mon").Value
End Sub

"Alan" wrote in message
...
Sorry, forgot to enter the subject,

Hi,
I'm using a Combobox from the Forms toolbar to select print ranges via

a
macro, the link cell for the Combobox being named "mon". What I have at

the
moment is:-

If Range("mon").Value = 1 Then ActiveSheet.PageSetup.PrintArea =
"$B$1:$AC$54"
If Range("mon").Value = 2 Then ActiveSheet.PageSetup.PrintArea =
"$AD$1:$BE$54"
If Range("mon").Value = 3 Then ActiveSheet.PageSetup.PrintArea =
"$BF$1:$CG$54"

and so on.
I want to do something like (I know this is wrong because it doesn't

work!)

ActiveSheet.PageSetup.PrintArea = Range([Whatever])

so that I can use a VLOOKUP using "mon" as the first argument in the
worksheet to put the required range in "Whatever" and use just one line of
code instead of 15 as I have at the moment.

I'm sure it can be done but I cant work out how. Can anyone please advise
me?
Hope I'm making sense,
Many thanks,
Regards,
Alan.

XL2002
WIN XP Professional




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 492
Default Print Ranges

Thats Great!
Thanks Tom and Bradley, much appreciated,
Regards,
Alan.

"Bradley Dawson" wrote in message
...
Name your print ranges "page1", "page2", etc. then use this code:

Sub PrntRng()
ActiveSheet.PageSetup.PrintArea = "page" & Range("mon").Value
End Sub

"Alan" wrote in message
...
Sorry, forgot to enter the subject,

Hi,
I'm using a Combobox from the Forms toolbar to select print ranges

via
a
macro, the link cell for the Combobox being named "mon". What I have at

the
moment is:-

If Range("mon").Value = 1 Then ActiveSheet.PageSetup.PrintArea =
"$B$1:$AC$54"
If Range("mon").Value = 2 Then ActiveSheet.PageSetup.PrintArea =
"$AD$1:$BE$54"
If Range("mon").Value = 3 Then ActiveSheet.PageSetup.PrintArea =
"$BF$1:$CG$54"

and so on.
I want to do something like (I know this is wrong because it doesn't

work!)

ActiveSheet.PageSetup.PrintArea = Range([Whatever])

so that I can use a VLOOKUP using "mon" as the first argument in the
worksheet to put the required range in "Whatever" and use just one line

of
code instead of 15 as I have at the moment.

I'm sure it can be done but I cant work out how. Can anyone please

advise
me?
Hope I'm making sense,
Many thanks,
Regards,
Alan.

XL2002
WIN XP Professional






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
Print Ranges based on conditions Courtney Excel Discussion (Misc queries) 0 July 16th 08 06:04 PM
How to print noncontiguous ranges? [email protected] Excel Discussion (Misc queries) 1 March 6th 07 11:47 PM
Print area composed by more ranges Andrea Excel Discussion (Misc queries) 2 February 21st 07 07:25 PM
Print Area ranges print on separate pages? Lyndon Excel Discussion (Misc queries) 1 December 29th 06 05:22 PM
Variable Print Ranges Zshepherd Excel Discussion (Misc queries) 0 December 2nd 04 03:23 PM


All times are GMT +1. The time now is 09:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"