Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2004
    Location
    Itasca, Illinois, USA
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel macro using IF statement (Excel 2000)

    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.

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Excel macro using IF statement (Excel 2000)

    What are the 10 cells to check?

    Steve

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Excel macro using IF statement (Excel 2000)

    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
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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