ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Printing If Cell Empty (https://www.excelbanter.com/excel-programming/372520-disable-printing-if-cell-empty.html)

Rob

Disable Printing If Cell Empty
 
I'm wondering if there is a way to disable the ability to print unless cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't seem to
work.

Any Ideas?

Thanks In Advance,
Rob

moon[_6_]

Disable Printing If Cell Empty
 

Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If


"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't seem to
work.

Any Ideas?

Thanks In Advance,
Rob




Rob

Disable Printing If Cell Empty
 
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If


"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't seem to
work.

Any Ideas?

Thanks In Advance,
Rob





moon[_6_]

Disable Printing If Cell Empty
 
It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If


"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't seem
to
work.

Any Ideas?

Thanks In Advance,
Rob







Rob

Disable Printing If Cell Empty
 
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't seem
to
work.

Any Ideas?

Thanks In Advance,
Rob







moon[_6_]

Disable Printing If Cell Empty
 

Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob









Rob

Disable Printing If Cell Empty
 
It still doesn't work.

If ActiveSheet.Range("B40") = False Or "" Then

Print #1,

End If

I don't know... It's got to be something.

"moon" wrote:


Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob










[email protected]

Disable Printing If Cell Empty
 
Hi Rob,

Try this one :

Sub tesprint()
If ActiveSheet.UsedRange = "" Then
MsgBox "Nothin' to print!"
Exit Sub
Else
'do your stuff here
End If
End Sub

rgds,

Halim



Rob menuliskan:
It still doesn't work.

If ActiveSheet.Range("B40") = False Or "" Then

Print #1,

End If

I don't know... It's got to be something.

"moon" wrote:


Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob











moon[_6_]

Disable Printing If Cell Empty
 

A Range or a Cell can not be True or False, only the value that's in there.
Print #1 is being used when writing data to a file, for a worksheet you'll
need PrintOut.
Try it again, but then referencing the cell-address instead of the range.

'Row 4, Column 2 = B4
If ActiveSheet.Cells(4, 2).Value < Empty Then
ActiveSheet.PrintOut
End If




"Rob" schreef in bericht
...
It still doesn't work.

If ActiveSheet.Range("B40") = False Or "" Then

Print #1,

End If

I don't know... It's got to be something.

"moon" wrote:


Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it
doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob












Rob

Disable Printing If Cell Empty
 
Well after much work and constant help from moon I finally found what works,
and that is...

If ActiveSheet.Range("B40") = "" Then
Cancel = True
End If

It stops the printing every time so far.

Thank You For all Your help and time.
Rob


"moon" wrote:


A Range or a Cell can not be True or False, only the value that's in there.
Print #1 is being used when writing data to a file, for a worksheet you'll
need PrintOut.
Try it again, but then referencing the cell-address instead of the range.

'Row 4, Column 2 = B4
If ActiveSheet.Cells(4, 2).Value < Empty Then
ActiveSheet.PrintOut
End If




"Rob" schreef in bericht
...
It still doesn't work.

If ActiveSheet.Range("B40") = False Or "" Then

Print #1,

End If

I don't know... It's got to be something.

"moon" wrote:


Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it
doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob













Tom Ogilvy

Disable Printing If Cell Empty
 
There isn't a separate msgbox function and and msgbox statement.

Just for clarity

There is only a msgbox function. If you choose not to use the returned
value, you don't put the arguments in parentheses (unless you preface it
with call). This is a VBA syntax rule.

All these work. All use the msgbox function

Sub AB()
MsgBox "First Fill In The Name", vbOKCancel
Call MsgBox("First Fill In The Name", vbOKCancel)
ans = MsgBox("First Fill In The Name", vbOKCancel)
End Sub

Just to cover all the bases, this will work
MsgBox ("First Fill In the Name")

but the parentheses around a single argument are interpreted for a different
purpose. They cause the argument to be evaluated - essentially forcing a
byVal argument.


--
Regards,
Tom Ogilvy

"moon" <6369706865725F6475646540706C616E65742E6E6C wrote in message
. ..

A Range or a Cell can not be True or False, only the value that's in
there.
Print #1 is being used when writing data to a file, for a worksheet you'll
need PrintOut.
Try it again, but then referencing the cell-address instead of the range.

'Row 4, Column 2 = B4
If ActiveSheet.Cells(4, 2).Value < Empty Then
ActiveSheet.PrintOut
End If




"Rob" schreef in bericht
...
It still doesn't work.

If ActiveSheet.Range("B40") = False Or "" Then

Print #1,

End If

I don't know... It's got to be something.

"moon" wrote:


Because the 'value' is always True, even if it's an empty value.
So...

If Application.ActiveSheet.Range("B40").Value < Empty Then
ActiveSheet.PrintOut
End If



"Rob" schreef in bericht
...
Ahhhh sweet. I tried your suggestion but it still prints.

"moon" wrote:

It means 'almost I guess'.
I'm just confusing newsgroups, that's all :-o



"Rob" schreef in bericht
...
Ummmm... What?

"moon" wrote:


Bijna... Denk ik.


If Application.ActiveSheet.Range("B40").Value = True Then
ActiveSheet.PrintOut
End If

"Rob" schreef in bericht
...
I'm wondering if there is a way to disable the ability to print
unless
cell
B40 is < FALSE, Something like this...


Sub ThisWorkbook_Print()

If Application.ActiveSheet.Range("B40").Value = False Then
Application.ActivePrinter = Nothing
End If

End Sub

I was hoping that the above code I made might do it but it
doesn't
seem
to
work.

Any Ideas?

Thanks In Advance,
Rob















All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com