Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Adjustable print range

Morning,

I have a file with 11 sheets and I need a macro to print sheets 2 and 4-11.
The print ranges are changeable every time on sheets 4 to 11.

Sheet 2 I need to print A20:N34
Sheets 4 to 11 I need to print A1:OX

In order to find the X I have a list of numbers in col R. Starting in row 1
to row X I have numbers greater than 0. Row X will have a number 0 and row
X+1 = 0, always.

Example 1 €“ in col R I have numbers that do 8 8 8 8 1 2 3 4 5 6 7 8 9 0 0 0
0 0 0 - print range needed is A1:O13
Example 2 €“ in col R I have numbers that do 3 3 3 3 1 2 3 4 0 0 0 0 0 0 -
print range needed A1:O8

In order to find the last row it can either be done by finding the cell at
which the R col changes to zero or the row at which max(R1:R100) occurs.

Is there a way to set a code to find the row reference I need and set an
adjustable rpint range accordingly?

Thanks
LiAD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Adjustable print range

Try the below

Sub Macro()
Dim intSheet As Integer, lngRow As Long

Sheets(2).Range("A20:N34").PrintOut Copies:=1, Collate:=True
For intSheet = 4 To 11
lngRow = Evaluate("=MAX(IF('" & Sheets(intSheet).Name & _
"'!R1:R100<0,ROW('" & Sheets(intSheet).Name & "'!R1:R100)))")
If lngRow < 0 Then
Sheets(intSheet).Range("A1:O" & lngRow).PrintOut Copies:=1, Collate:=True
End If
Next

End Sub


--
Jacob


"LiAD" wrote:

Morning,

I have a file with 11 sheets and I need a macro to print sheets 2 and 4-11.
The print ranges are changeable every time on sheets 4 to 11.

Sheet 2 I need to print A20:N34
Sheets 4 to 11 I need to print A1:OX

In order to find the X I have a list of numbers in col R. Starting in row 1
to row X I have numbers greater than 0. Row X will have a number 0 and row
X+1 = 0, always.

Example 1 €“ in col R I have numbers that do 8 8 8 8 1 2 3 4 5 6 7 8 9 0 0 0
0 0 0 - print range needed is A1:O13
Example 2 €“ in col R I have numbers that do 3 3 3 3 1 2 3 4 0 0 0 0 0 0 -
print range needed A1:O8

In order to find the last row it can either be done by finding the cell at
which the R col changes to zero or the row at which max(R1:R100) occurs.

Is there a way to set a code to find the row reference I need and set an
adjustable rpint range accordingly?

Thanks
LiAD

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Adjustable print range

Perfecto

Thanks a lot

"Jacob Skaria" wrote:

Try the below

Sub Macro()
Dim intSheet As Integer, lngRow As Long

Sheets(2).Range("A20:N34").PrintOut Copies:=1, Collate:=True
For intSheet = 4 To 11
lngRow = Evaluate("=MAX(IF('" & Sheets(intSheet).Name & _
"'!R1:R100<0,ROW('" & Sheets(intSheet).Name & "'!R1:R100)))")
If lngRow < 0 Then
Sheets(intSheet).Range("A1:O" & lngRow).PrintOut Copies:=1, Collate:=True
End If
Next

End Sub


--
Jacob


"LiAD" wrote:

Morning,

I have a file with 11 sheets and I need a macro to print sheets 2 and 4-11.
The print ranges are changeable every time on sheets 4 to 11.

Sheet 2 I need to print A20:N34
Sheets 4 to 11 I need to print A1:OX

In order to find the X I have a list of numbers in col R. Starting in row 1
to row X I have numbers greater than 0. Row X will have a number 0 and row
X+1 = 0, always.

Example 1 €“ in col R I have numbers that do 8 8 8 8 1 2 3 4 5 6 7 8 9 0 0 0
0 0 0 - print range needed is A1:O13
Example 2 €“ in col R I have numbers that do 3 3 3 3 1 2 3 4 0 0 0 0 0 0 -
print range needed A1:O8

In order to find the last row it can either be done by finding the cell at
which the R col changes to zero or the row at which max(R1:R100) occurs.

Is there a way to set a code to find the row reference I need and set an
adjustable rpint range accordingly?

Thanks
LiAD

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
adjustable range radar chart Guerillamjk Charts and Charting in Excel 0 March 27th 10 03:32 PM
Adjustable Macro Code???? Loopi Excel Programming 4 February 5th 09 02:40 AM
Chart adjustable range iperlovsky Charts and Charting in Excel 2 May 15th 08 09:40 PM
Adjustable Font Size Darren Hill Excel Programming 6 October 17th 07 05:53 PM
Adjustable Rate APR Xhawk57 Excel Discussion (Misc queries) 4 February 15th 06 06:14 PM


All times are GMT +1. The time now is 11:02 PM.

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"