Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide rows after testing 2 cells (2003)

    I wish to hide a row if 2 cells in the same row are empty, eg the cell in column A and column X.

    My spreadsheet currently tests for one cell & that works great, as follows:
    blnHideHeader = True
    'set up the range
    lngMaxRow = Range("A65536").End(xlUp).Row
    For lngRow = lngMaxRow To 7 Step -1
    If Cells(lngRow, 17) = "" Then
    ' heading
    Rows(lngRow).Hidden = blnHideHeader
    blnHideHeader = True
    ElseIf Cells(lngRow, 18) = "" Then
    Rows(lngRow).Hidden = True
    Else
    blnHideHeader = False
    End If
    Next lngRow

    But what if I want to test by 2 cells? How can I do this?

    Thanks in advance!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide rows after testing 2 cells (2003)

    Try this:

    'set up the range
    lngMaxRow = Range("A65536").End(xlUp).Row
    For lngRow = lngMaxRow To 7 Step -1
    ' Test cells in column A and X
    If Cells(lngRow, 1) = "" And Cells(lngRow, 24) = "" Then
    Rows(lngRow).Hidden = True
    End If
    Next lngRow

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide rows after testing 2 cells (2003)

    Thanks Hans, works perfectly.

    Much appreciated.

Posting Permissions

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