Forum Discussion
Hide rows in a different sheet based on a value (that contains specific letters)
The code is the Worksheet_Change event procedure of Sheet1. It runs automatically when you change the value of one or more cells on Sheet1.
The code first checks whether the changed cell is in column D.
If so, it unhides the corresponding row on Sheet2, then checks the new value of the cell. If it contains "ab, "ma" or "om", it hides the corresponding row on Sheet2, otherwise it leaves it visible.
Since the code reacts to you changing a cell, it "knows" which row to hide/unhide on Sheet2: the row with the same number.
- HansVogelaarJul 24, 2022MVP
Apparently, I have completely misinterpreted your request. Now I don't understand anymore.
How should I know that you want to look for "ba" if you write "Baby"?
- Steiny88Jul 24, 2022Copper ContributorI didn't say ba, I want to look for ab and this is just an example. The original file it's different but I will modify it so I need only the code. The word doesn't matter, only the condition to check for the specific letters and ab is just an example. If it sees ab somewhere in column D on sheet1 to choose which rows to hide on sheet2. This is what I need. I hope that helped.
- HansVogelaarJul 24, 2022MVP
Sorry, my mistake. How should I know that you want to look for "ab" if you enter Baby?