If....Or Logic question

S

Stuart

Here's the code:

If (Global_PrintZeroPages = False Or _
Global_PrintBlankPages = False) Then
If Not Pagevarr(i + 1).Offset(-1, £Col).Value _
"0.00" Then
GoTo Line200
End If
End If

The code should test the 2 'Global' variables (dimmed as
Boolean). If either are set to False, then it should look at
the value in the range Pagevarr(i + 1).Offset(-1, £Col).

If "Global_PrintZeroPages = False" is True then it should
test for the value "0.00". If "Global_PrintBlankPages = False"
is True, then it should check for an empty cell (ie no textual
nor numeric entry).

If either value meets the criteria, then GoTo Line200, else
continue the routine.

How do I achieve this please?

Regards.
 
T

Tom Ogilvy

A =Global_PrintZeroPages
B = Global_PrintBlankPages
C = Pagevarr(i + 1).Offset(-1, £Col).Value

if A and B then
' do nothing, both true
elseif Not A and B then
if c= 0 then goto Line200
elseif A and Not B then
if isempty(c) then goto Line200
else ' both are false
' do what
End if
 
G

George Nicholson

Note: 2 possible approaches.

Approach1:
If (Global_PrintZeroPages = False) OR (Global_PrintBlankPages = False) Then
' If either is true, check Pagevarr for *Either* condition
Select Case Pagevarr(i + 1).Offset(-1, £Col).Value
Case Null
GoTo Line200
Case > "0.00"
' Continue
Case Else
GoTo Line200
End Select
End If

Approach2:
' If individual statement is true, check Pagevar for specific condition
' Note: Is there any problem if we "GoTo Line 200" more than once? Any
chance we might?

If Global_PrintZeroPages = False Then
If Not Pagevarr(i + 1).Offset(-1, £Col).Value "0.00" Then
GoTo Line200
End If
End If

If Global_PrintBlankPages = False Then
If Len(Pagevarr(i + 1).Offset(-1, £Col).Value) = 0 Then
GoTo Line200
End If
End If
 
S

Stuart

Many thanks.
' Note: Is there any problem if we "GoTo Line 200" more than once? Any
chance we might?

Printvarr effectively defines the Printareas in the sheet being processed
Pagevarr(i) holds the value (found in col A) that marks the start
of each 'page' to be printed. Thus Pagevarr(i + 1).Offset(-1, £Col).Value
can be used to find the 'Summary' value for that 'page'.
If user has not requested a print of zero or blank 'pages' then I need to
exclude the print (hence a "cop-out" to Line200) of this particular
printarea,
but continue the loop to consider other printareas (defined by the array
Printvarr).

For i = 1 To UBound(Printvarr)
If £Col = 14 And Columns(£Col).EntireColumn.Hidden _
= True Then
With Pagevarr(i + 1).Offset(-1, (£Col - 2))
.Value = "£"
End With
End If
If (Global_PrintZeroPages = False Or _
Global_PrintBlankPages = False) Then
If Not Pagevarr(i + 1).Offset(-1, £Col).Value _
"0.00" Then
GoTo Line200
End If
End If

'for testing, toggle as required
' Printvarr(i).PrintOut
Printvarr(i).PrintPreview
Line200:
Next

If I've missed anything in your post, then please educate.

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top