A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

conditional printing? macro?



 
 
Thread Tools Display Modes
  #1  
Old May 13th, 2004, 03:30 PM
Steven
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

here's my situation, i have a workbook with many sheets in it, each sheet if
the default print shortcut button was used would print to 4 pages of A4
paper.

the data on these sheets varies everyday, someday's only 1 page per sheet
would be full of data others 2, 3, or 4 etc. how could i write a macro that
would be able to print only the needed pages?, each page, if it contains any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set data1 = TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set data2 = TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set data3 = TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set data4 = TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't print")

Hope this helps to explain what im trying to do, and someone is able to code
something that would work.

Many thanks,
Steve


  #2  
Old May 13th, 2004, 04:25 PM
Ron de Bruin
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each sheet if
the default print shortcut button was used would print to 4 pages of A4
paper.

the data on these sheets varies everyday, someday's only 1 page per sheet
would be full of data others 2, 3, or 4 etc. how could i write a macro that
would be able to print only the needed pages?, each page, if it contains any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set data1 = TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set data2 = TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set data3 = TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set data4 = TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't print")

Hope this helps to explain what im trying to do, and someone is able to code
something that would work.

Many thanks,
Steve




  #3  
Old May 13th, 2004, 05:22 PM
Steven
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each

sheet if
the default print shortcut button was used would print to 4 pages of A4
paper.

the data on these sheets varies everyday, someday's only 1 page per

sheet
would be full of data others 2, 3, or 4 etc. how could i write a macro

that
would be able to print only the needed pages?, each page, if it contains

any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set data1 =

TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set data2 =

TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set data3 =

TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set data4 =

TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't print")

Hope this helps to explain what im trying to do, and someone is able to

code
something that would work.

Many thanks,
Steve






  #4  
Old May 13th, 2004, 06:09 PM
Ron de Bruin
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message news
Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each

sheet if
the default print shortcut button was used would print to 4 pages of A4
paper.

the data on these sheets varies everyday, someday's only 1 page per

sheet
would be full of data others 2, 3, or 4 etc. how could i write a macro

that
would be able to print only the needed pages?, each page, if it contains

any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set data1 =

TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set data2 =

TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set data3 =

TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set data4 =

TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't print")

Hope this helps to explain what im trying to do, and someone is able to

code
something that would work.

Many thanks,
Steve








  #5  
Old May 13th, 2004, 07:02 PM
steveb
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

How about instead of ActiveSheet.PrintOut set up a way to get the range for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)


"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news
Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each

sheet if
the default print shortcut button was used would print to 4 pages of

A4
paper.

the data on these sheets varies everyday, someday's only 1 page per

sheet
would be full of data others 2, 3, or 4 etc. how could i write a

macro
that
would be able to print only the needed pages?, each page, if it

contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set

data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set

data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set

data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set

data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't

print")

Hope this helps to explain what im trying to do, and someone is able

to
code
something that would work.

Many thanks,
Steve










  #6  
Old May 13th, 2004, 11:59 PM
Dave Peterson
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

Or maybe:

Option Explicit
Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut preview:=True, From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut preview:=True, From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut preview:=True, From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut preview:=True, From:=4, To:=4
End Sub

it worked ok for me in xl2002.




steveb wrote:

How about instead of ActiveSheet.PrintOut set up a way to get the range for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news
Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each
sheet if
the default print shortcut button was used would print to 4 pages of

A4
paper.

the data on these sheets varies everyday, someday's only 1 page per
sheet
would be full of data others 2, 3, or 4 etc. how could i write a

macro
that
would be able to print only the needed pages?, each page, if it

contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set

data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set

data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set

data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set

data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't

print")

Hope this helps to explain what im trying to do, and someone is able

to
code
something that would work.

Many thanks,
Steve









--

Dave Peterson

  #7  
Old May 14th, 2004, 02:59 PM
Ron de Bruin
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

Thanks Dave

I never use it like this
I always waste treesg

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Dave Peterson" wrote in message ...
Or maybe:

Option Explicit
Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut preview:=True, From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut preview:=True, From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut preview:=True, From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut preview:=True, From:=4, To:=4
End Sub

it worked ok for me in xl2002.




steveb wrote:

How about instead of ActiveSheet.PrintOut set up a way to get the range for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news
Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each
sheet if
the default print shortcut button was used would print to 4 pages of

A4
paper.

the data on these sheets varies everyday, someday's only 1 page per
sheet
would be full of data others 2, 3, or 4 etc. how could i write a

macro
that
would be able to print only the needed pages?, each page, if it

contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set

data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set

data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set

data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set

data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't

print")

Hope this helps to explain what im trying to do, and someone is able

to
code
something that would work.

Many thanks,
Steve









--

Dave Peterson



  #8  
Old May 15th, 2004, 12:10 AM
Dave Peterson
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

For the most part, I keep my (personal) printer off.

In fact, it's paused (under control panel).

Before I did this, I used all the trees in the Sahara Forest. Well, it's a
desert NOW!

(It's an old joke, but I'm an old man!)



Ron de Bruin wrote:

Thanks Dave

I never use it like this
I always waste treesg

--
Regards Ron de Bruin
http://www.rondebruin.nl

"Dave Peterson" wrote in message ...
Or maybe:

Option Explicit
Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut preview:=True, From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut preview:=True, From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut preview:=True, From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut preview:=True, From:=4, To:=4
End Sub

it worked ok for me in xl2002.




steveb wrote:

How about instead of ActiveSheet.PrintOut set up a way to get the range for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it, each
sheet if
the default print shortcut button was used would print to 4 pages of
A4
paper.

the data on these sheets varies everyday, someday's only 1 page per
sheet
would be full of data others 2, 3, or 4 etc. how could i write a
macro
that
would be able to print only the needed pages?, each page, if it
contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set
data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set
data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set
data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set
data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't
print")

Hope this helps to explain what im trying to do, and someone is able
to
code
something that would work.

Many thanks,
Steve









--

Dave Peterson


--

Dave Peterson

  #9  
Old May 16th, 2004, 05:34 PM
Steven
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

what code would i need to use on new commandbutton to do the following:

1) select sheet 1
2) run another commandbutton from within that sheet "Private Sub
CommandButton2_Click()
SortKeys = "EC"
Call SortAllRanges
End Sub"
3) look at "total4" if greater than 0 print pages 1 to 4, 1 copy, goto next
else
look at "total3" if greater than 0 print pages 1 to
3, 1 copy, goto next
else
look at "total2" if greater
than 0 print pages 1 to 2, 1 copy, goto next
else
look at
"total1" if greater than 0 print pages 1 to 1, 1 copy, goto next

else

end if
4) select sheet 2
5) same as 2)
6) same as 3)
7) select sheet 3

i would be very grateful for your help as this would enable me to setup lots
of different auto print options for multiple worksheets.

Steve

"Dave Peterson" wrote in message
...
Or maybe:

Option Explicit
Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut preview:=True, From:=1,

To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut preview:=True, From:=2,

To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut preview:=True, From:=3,

To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut preview:=True, From:=4,

To:=4
End Sub

it worked ok for me in xl2002.




steveb wrote:

How about instead of ActiveSheet.PrintOut set up a way to get the range

for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message

news
Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it,

each
sheet if
the default print shortcut button was used would print to 4

pages of
A4
paper.

the data on these sheets varies everyday, someday's only 1 page

per
sheet
would be full of data others 2, 3, or 4 etc. how could i write a

macro
that
would be able to print only the needed pages?, each page, if it

contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set

data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set

data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set

data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set

data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't

print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't

print")

Hope this helps to explain what im trying to do, and someone is

able
to
code
something that would work.

Many thanks,
Steve









--

Dave Peterson



  #10  
Old May 16th, 2004, 09:48 PM
Dave Peterson
external usenet poster
 
Posts: n/a
Default conditional printing? macro?

One way:

If Range("total4").Value 0 Then
ActiveSheet.PrintOut preview:=True, From:=4, To:=4
ElseIf Range("total3").Value 0 Then
ActiveSheet.PrintOut preview:=True, From:=3, To:=3
ElseIf Range("total2").Value 0 Then
ActiveSheet.PrintOut preview:=True, From:=2, To:=2
ElseIf Range("total1").Value 0 Then
ActiveSheet.PrintOut preview:=True, From:=1, To:=1
Else
'do nothing
End If



Steven wrote:

what code would i need to use on new commandbutton to do the following:

1) select sheet 1
2) run another commandbutton from within that sheet "Private Sub
CommandButton2_Click()
SortKeys = "EC"
Call SortAllRanges
End Sub"
3) look at "total4" if greater than 0 print pages 1 to 4, 1 copy, goto next
else
look at "total3" if greater than 0 print pages 1 to
3, 1 copy, goto next
else
look at "total2" if greater
than 0 print pages 1 to 2, 1 copy, goto next
else
look at
"total1" if greater than 0 print pages 1 to 1, 1 copy, goto next

else

end if
4) select sheet 2
5) same as 2)
6) same as 3)
7) select sheet 3

i would be very grateful for your help as this would enable me to setup lots
of different auto print options for multiple worksheets.

Steve

"Dave Peterson" wrote in message
...
Or maybe:

Option Explicit
Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut preview:=True, From:=1,

To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut preview:=True, From:=2,

To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut preview:=True, From:=3,

To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut preview:=True, From:=4,

To:=4
End Sub

it worked ok for me in xl2002.




steveb wrote:

How about instead of ActiveSheet.PrintOut set up a way to get the range

for
the area to print and return it in a MsgBox?
or DeBug Print? or....

--
steveb
(Remove 'NOSPAM' from email address if replying direct)

"Ron de Bruin" wrote in message
...
Printpreview will not work with From:=1, To:=1

You must print

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news Thanks Ron,
how could i test this without printing? if possible?

Steve

"Ron de Bruin" wrote in message
...
Hi Steven

Try this

Sub test()
If Range("total1") 0 Then ActiveSheet.PrintOut From:=1, To:=1
If Range("total2") 0 Then ActiveSheet.PrintOut From:=2, To:=2
If Range("total3") 0 Then ActiveSheet.PrintOut From:=3, To:=3
If Range("total4") 0 Then ActiveSheet.PrintOut From:=4, To:=4
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steven" wrote in message
news:kELoc.118$6X5.92@newsfe1-win...
here's my situation, i have a workbook with many sheets in it,

each
sheet if
the default print shortcut button was used would print to 4

pages of
A4
paper.

the data on these sheets varies everyday, someday's only 1 page

per
sheet
would be full of data others 2, 3, or 4 etc. how could i write a
macro
that
would be able to print only the needed pages?, each page, if it
contains
any
data would have a value in a totals cell.

so i would need code along these lines

Sheets("sheet1").Select
IF(OR(total1="",total1=0),"don't print","don't print") ELSE set
data1 =
TRUE
IF(OR(total2="",total2=0),"don't print","don't print") ELSE set
data2 =
TRUE
IF(OR(total3="",total3=0),"don't print","don't print") ELSE set
data3 =
TRUE
IF(OR(total4="",total4=0),"don't print","don't print") ELSE set
data4 =
TRUE

IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 1", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 2", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 3", "don't
print")
IF(OR(data1 ="TRUE",data1="FALSE"),"Print Page 1 to 4", "don't
print")

Hope this helps to explain what im trying to do, and someone is

able
to
code
something that would work.

Many thanks,
Steve









--

Dave Peterson


--

Dave Peterson

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:00 AM.


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