Group:  Microsoft Excel ยป microsoft.public.excel.programming
Thread: Print Code

Geek News

Print Code
Randy 12/31/2008 7:05:02 PM
Greetings...

I have a little code I am needing some assistance with. The code is suppose
to print out certain sheets based on wether a particular cell on another
sheet is empty or not. If the cell is empty the sheet should not print...if
cell is not empty, the sheet should print.

Here is what I have....any assistance will be greatly appreciated! ..................................................................................................
Private Sub Print_All_Click()
Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
If Not IsEmpty("D20") Then
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
Else
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
End If
End Sub ..................................................................................................

Thanks again and have a wonderful and safe New Year celebration!
--
Randy Street
Rancho Cucamonga, CA
Re: Print Code
Leith Ross <Leith.Ross.3latlg[ at ]thecodecage.com> 12/31/2008 7:52:26 PM
Randy;163997 Wrote: > Greetings...
[Quoted Text]
>
> I have a little code I am needing some assistance with. The code is > suppose
> to print out certain sheets based on wether a particular cell on > another
> sheet is empty or not. If the cell is empty the sheet should not > print...if
> cell is not empty, the sheet should print.
>
> Here is what I have....any assistance will be greatly appreciated!
> ..................................................................................................
> Private Sub Print_All_Click()
> Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
> If Not IsEmpty("D20") Then
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
> Else
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
> End If
> End Sub
> ..................................................................................................
>
> Thanks again and have a wonderful and safe New Year celebration!
> --
> Randy Street
> Rancho Cucamonga, CA

Hello Randy,

Your IF statement is tautological. That is it always evaluates to the same result.

If Not IsEmpty("D20") Then
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
Else
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
End If

Change it to this...

If Not IsEmpty("D20") Then
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
End If

Sincerely,
Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75 View this thread: http://www.thecodecage.com/forumz/showthread.php?t=45557
RE: Print Code
JLGWhiz 12/31/2008 7:56:07 PM
Randy, If you have a formula in cell D20 the IsEmpty function will not work.
Also, If you do not want to print, you do not need the Else part of the If
.... Then statement because if it is not true it will not print. Here is my
suggestion.

Private Sub Print_All_Click()
Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
If Range("D20").Value > "" Then
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
End If
End Sub


"Randy" wrote:

[Quoted Text]
> Greetings...
>
> I have a little code I am needing some assistance with. The code is suppose
> to print out certain sheets based on wether a particular cell on another
> sheet is empty or not. If the cell is empty the sheet should not print...if
> cell is not empty, the sheet should print.
>
> Here is what I have....any assistance will be greatly appreciated!
> .................................................................................................
> Private Sub Print_All_Click()
> Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
> If Not IsEmpty("D20") Then
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
> Else
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
> End If
> End Sub
> .................................................................................................
>
> Thanks again and have a wonderful and safe New Year celebration!
> --
> Randy Street
> Rancho Cucamonga, CA
RE: Print Code
Mike H 12/31/2008 7:57:01 PM
Randy,

Maybe this. It will print sheet "Commission Pool" with no criteria. Note
I've qualified the D20 name with a sheet name

Private Sub Print_All_Click()
Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
If Not IsEmpty(Sheets("YourSheet").Range("D20")) Then
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
End If
End Sub

Mike

"Randy" wrote:

[Quoted Text]
> Greetings...
>
> I have a little code I am needing some assistance with. The code is suppose
> to print out certain sheets based on wether a particular cell on another
> sheet is empty or not. If the cell is empty the sheet should not print...if
> cell is not empty, the sheet should print.
>
> Here is what I have....any assistance will be greatly appreciated!
> .................................................................................................
> Private Sub Print_All_Click()
> Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
> If Not IsEmpty("D20") Then
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
> Else
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
> End If
> End Sub
> .................................................................................................
>
> Thanks again and have a wonderful and safe New Year celebration!
> --
> Randy Street
> Rancho Cucamonga, CA
RE: Print Code
Randy 12/31/2008 9:03:01 PM
And the winner is....Mike H.!!!! lol...just kidding...Thanks a bunch to
everyone who took the time to help me out with this. I really appreciate it!

Now I kind of have one more little question......lets say cells D20:D23
(below) are all empty/blank...how can I "stop" the "Commission Pool" sheet
from printing if "all" cells are blank, but still print even if one of the
cells in the range is "not" blank?

Maybe there is even a better (shorter) way of doing this:

Private Sub Print_All_Click()
ActiveWorkbook.Unprotect Password:="XXXXXX"
Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
If Not IsEmpty(Sheets("Commission Pool").Range("D20")) Then
Sheets("Sr-Area Manager").Visible = True
Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
Sheets("Sr-Area Manager").Visible = False
End If
If Not IsEmpty(Sheets("Commission Pool").Range("D21")) Then
Sheets("Community Manager").Visible = True
Sheets("Community Manager").PrintOut Copies:=1, Collate:=True
Sheets("Community Manager").Visible = False
End If
If Not IsEmpty(Sheets("Commission Pool").Range("D22")) Then
Sheets("Assistant Manager").Visible = True
Sheets("Assistant Manager").PrintOut Copies:=1, Collate:=True
Sheets("Assistant Manager").Visible = False
End If
If Not IsEmpty(Sheets("Commission Pool").Range("D23")) Then
Sheets("Leasing Agent (1)").Visible = True
Sheets("Leasing Agent (1)").PrintOut Copies:=1, Collate:=True
Sheets("Leasing Agent (1)").Visible = False
End If
ActiveWorkbook.Protect Password:="XXXXXX"



--
Randy Street
Rancho Cucamonga, CA


"Mike H" wrote:

[Quoted Text]
> Randy,
>
> Maybe this. It will print sheet "Commission Pool" with no criteria. Note
> I've qualified the D20 name with a sheet name
>
> Private Sub Print_All_Click()
> Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
> If Not IsEmpty(Sheets("YourSheet").Range("D20")) Then
> Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
> End If
> End Sub
>
> Mike
>
> "Randy" wrote:
>
> > Greetings...
> >
> > I have a little code I am needing some assistance with. The code is suppose
> > to print out certain sheets based on wether a particular cell on another
> > sheet is empty or not. If the cell is empty the sheet should not print...if
> > cell is not empty, the sheet should print.
> >
> > Here is what I have....any assistance will be greatly appreciated!
> > .................................................................................................
> > Private Sub Print_All_Click()
> > Sheets("Commission Pool").PrintOut Copies:=1, Collate:=True
> > If Not IsEmpty("D20") Then
> > Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=True
> > Else
> > Sheets("Sr-Area Manager").PrintOut Copies:=1, Collate:=False
> > End If
> > End Sub
> > .................................................................................................
> >
> > Thanks again and have a wonderful and safe New Year celebration!
> > --
> > Randy Street
> > Rancho Cucamonga, CA

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net