Jul 24 2022 01:49 AM
I have 2 sheets and attached an example:
Sheet1 D8 has Baby as value
Sheet1 D9 has Man as value
Sheet1 D10 has Woman as value
The code to search for "ab" in column D and if it finds it somewhere to hide row 8 from sheet2
Second condition is to search for ma in column D to hide row 9 from sheet2
Third condition is to search for om in column D to hide row 10 from sheet2
FYI - I will need to have 6 more conditions, but let's see if there is such code where it searches for containing letters in a column and also the code to be automatic not to run it every time and if there is nothing written in column D to
unhide all rows from sheet2.
Thank You!
Jul 24 2022 02:49 AM
"ma" occurs in D9 and D10. Doesn't that cause confusion?
Jul 24 2022 03:19 AM
Jul 24 2022 03:46 AM
See the attached workbook. It is now a macro-enabled workbook (*.xlsm) so you'll have to allow macros when you open it.
To view the code, right-click the sheet tab of Sheet1 and select 'View Code' from the context menu.
Jul 24 2022 07:30 AM
Jul 24 2022 07:40 AM
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.
Jul 24 2022 07:53 AM
Jul 24 2022 08:13 AM
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"?
Jul 24 2022 08:20 AM
Jul 24 2022 08:46 AM
Sorry, my mistake. How should I know that you want to look for "ab" if you enter Baby?
Jul 24 2022 09:03 AM
Jul 24 2022 09:04 AM
I don't understand either. I give up for now.