Consulting

Results 1 to 2 of 2

Thread: If condition for stop printing sheet

  1. #1
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location

    If condition for stop printing sheet

    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

  2. #2
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    Anybody reply me for complete the above condition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •