Excel VBA Code to Hide rows based on Criteria

  • Hey i have this code that i use to sort my worksheet however i want to include a special provision where if the text in the Range of column "C" equals "TOTAL" do not hide the empty row under it.


    For example i want the worksheet to have a row separating my tables after the, text TOTAL.


    Right now it hides every row with a empty space in the range but i want to not hide the row if the cell above that CURRENT cell reads "TOTAL"


    this is the code :

  • Hi,


    How about something like this:



    Note that deleting rows can be tricky - you might want to look at looping backwards (ie from the bottom to the top).

  • Hi,


    You can test the following :



    Hope this will help


    Edit : Oops ... too Late ... :smile:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Thanks [USER="31712"]Carim[/USER] didnt get a chance to use yours because [USER="333350"]Excel_Phoenix[/USER] Code worked great!


    Thanks for help !

  • [USER="31712"]Carim[/USER] just checked your code works when you change the offset to (-1,0) but good job dude! great work

  • Quite honestly was a bit confused ... since in your initial message ...


    the first sentence says :

    Quote

    do not hide the empty row under it.


    the second sentence says :

    Quote

    not hide the row if the cell above that CURRENT


    Now you do have both ....:sing:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

Participate now!

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