• Excel macro using IF statement (Excel 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Excel macro using IF statement (Excel 2000)

    Author
    Topic
    #406563

    I need to write a print macro that will first run an IF Statement to hide rows before printing. Basically, if ten cells on the row are blank, then hide the row, then set the print range to print. Can this be done? Any suggestions. Normally the print range will be a1: m100. However, if on any row, ten specific cells are blank, I would like to hide the row and then print with the smaller area. Thank you.

    Viewing 3 reply threads
    Author
    Replies
    • #844111

      What are the 10 cells to check?

      Steve

    • #844112

      What are the 10 cells to check?

      Steve

    • #844123

      If you hide the rows, then the area will be smaller. This code may need more error handling but should get you started.

      Sub HideRowsWith10OrMoreBlanksThenprint()
      Dim lngC As Long
      Application.ScreenUpdating = False
      With Worksheets(“Sheet1”)
      For lngC = 0 To 99
      If Application.WorksheetFunction.CountBlank(Range([A1].Offset(lngC, 0), [A1].Offset(lngC, 13))) >= 10 Then _
      [A1].Offset(lngC, 0).EntireRow.Hidden = True
      Next lngC
      .Range(“A1:M100”).PrintOut
      End With
      Application.ScreenUpdating = False
      End Sub

    • #844124

      If you hide the rows, then the area will be smaller. This code may need more error handling but should get you started.

      Sub HideRowsWith10OrMoreBlanksThenprint()
      Dim lngC As Long
      Application.ScreenUpdating = False
      With Worksheets(“Sheet1”)
      For lngC = 0 To 99
      If Application.WorksheetFunction.CountBlank(Range([A1].Offset(lngC, 0), [A1].Offset(lngC, 13))) >= 10 Then _
      [A1].Offset(lngC, 0).EntireRow.Hidden = True
      Next lngC
      .Range(“A1:M100”).PrintOut
      End With
      Application.ScreenUpdating = False
      End Sub

    Viewing 3 reply threads
    Reply To: Excel macro using IF statement (Excel 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: