Hide Rows Based On Sum Of 2 Columns

  • Hi All,


    I'm looking for code to hide all rows but the header row if the sum in two different columns both equal 0, otherwise no action is required. I've attached a spreadsheet as an example. I found similiar topics while searching but was unable to adapt anything for my needs.
    Again, I need to hide all rows but the header, if both the amounts in column Z total 0 and the amounts in column AJ total 0.



    Thanks for any assistance.


    JL

  • Re: Hide Rows Based On Multiple Criteria


    Does this help


    Code
    Sub HideRows()
    
    
        Rows("2:11").EntireRow.Hidden = _
        IIf(Range("Z7").Value = Range("AJ7").Value, True, False)
    End Sub


    VBA Noob

  • Re: Hide Rows Based On Multiple Criteria


    Thanks so much VBA Noob. That helped out alot! I was having trouble figuring out how to account for the fact that the rows would vary from day to day, but this seems to work for the variance.


    Code
    Sub HideRows()
         
        Rows("2:11").EntireRow.Hidden = _
        IIf(Range("Z65536").End(xlUp).Value = Range("AJ65536").End(xlUp).Value, True, False)
    End Sub


    Thanks again for the assist. :)


    JL

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!