PDA

View Full Version : If condition for stop printing sheet



elsuji
09-17-2019, 06:25 AM
Hi,

I am using the following code to print sheets in PDF format.



Dim a1, b1, aa, bb, i, pdf As String
a1 = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5", "Sheet6", "Sheet8")
b1 = Array("Sheet1", "Sheet2", "Sheet3.a", "Sheet4", "Sheet7", "Sheet8")
pdf = ThisWorkbook.FullName
'Get sheet's visible property, and set to xlSheetVisible
aa = a1
For i = 0 To UBound(a1)
aa(i) = Worksheets(a1(i)).Visible 'Errors if sheet a(i) does not exist.
Worksheets(a1(i)).Visible = xlSheetVisible
Next i
bb = b1
For i = 0 To UBound(b1)
bb(i) = Worksheets(b1(i)).Visible 'Errors if sheet a(i) does not exist.
Worksheets(b1(i)).Visible = xlSheetVisible
Next i
If Sheets("Data").Range("C11").Value = "" Then
Sheets(a1).Select
Else
Sheets(b1).Select 'Make sheets grouped.
End If
ActiveSheet.ExportAsFixedFormat xlTypePDF, pdf, xlQualityStandard, True, False, , , True
Sheets(1).Select 'ungroup sheets
'After export hide sheets
For i = 0 To UBound(a1)
Worksheets(a1(i)).Visible = False
Next i
For i = 0 To UBound(b1)
Worksheets(b1(i)).Visible = False
Next i


End Sub


I am having datas updating in Sheet "Data" range is H30:I136. If the value >= 2 then it should not print the document and message to be display " value is exceeded"

can any one help me to this condition

elsuji
09-17-2019, 11:12 AM
Anybody reply me for complete the above condition