View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Print Button Macro with Multiple Conditions

Hi Gerard,

When I compare this post to your earlier one I am wondering exactly what
conditions you want met or (Not met) to fail the print. The code you have
posted here requires all of the conditions set to be met before print fails.

I thought in your earlier post that any one of the conditions should cause
failure to print so should it be And or should it be Or?

Anyway to answer this post I assume you simply want the syntax for the last
part of the If test so try the following code. If you want the print to fail
if only one of the conditions are met then change And to Or. Also with count
function if you want print to FAIL when =1 then code OK but if you want it to
print when = 1 then change =1 to <1.

Note that COUNT function counts cells with numbers. COUNTA functions counts
the number of non empty cells (Includes cells containing numbers as well as
other non empty cells.)

Sub PrintWithConditionsTest()

If Range("G59") = "Select Customer" And _
Range("F64") = "Select User" And _
Range("F65") = "Not Balanced !" And _
WorksheetFunction.Count(Range("C61"), _
Range("C62"), Range("F61"), Range("F62"), _
Range("I61"), Range("I62")) = 1 Then

MsgBox "Required information not filled and/or Discrepancy exists!"

Else

Range("A18:I69").PrintOut Copies:=1

End If
End Sub


Re-post as a reply to this if not what you want rather than create a new post.

--
Regards,

OssieMac


"Gerard Sanchez" wrote:

Hi,

'Here is what I am trying to do:

Sub PrintWithConditions()

If Range("G59") = "Select Customer" And _
Range("F64") = "Select User" And _
Range("F65") = "Not Balanced !" And _
Count(Range(C61,C62,F61,F62,I61,I62) 0 < 2 Then

MsgBox "Required information not filled and/or Discrepancy exists!"

Else
Range("A18:I69").PrintOut Copies:=1

End If
End Sub


'For ranges C61,C62,F61,F62,I61,I62, I just want one (1) of these cells with
a value

'I am working on a worksheets that have 25 pages and that
'hopefully if I can get this right, I can just change the range values and
assign it to
'other buttons on separate pages of the same worksheet.

'Can anyone help me on this ??