Forum Discussion
Hiding Columns Based on a Cell Value
- Mar 15, 2020
SamFares40 your problem is WHERE you put that VBA code. You put it in Module1, but the Worksheet_SelectionChange needs to be in the sheet it is meant to act on, in this case Sheet1 (expand Microsoft Excel Objects to find it). I move it to that code sheet and it worked fine.
SamFares40 Tried your code, without any modification. Works perfect on my end. BUT.... be aware that when cell B4 is empty it is also seen as -zero- and column H gets hidden. Enter anything else, and column H reappears.
Thank you Riny_van_Eekelen!!
Did you use the excel sheet that i attached. In the screen shot below from the excel sheet that i uploaded earlier, it is not hiding column "H". What am I doing wrong?
Thanks,
Sam
- Riny_van_EekelenMar 15, 2020Platinum Contributor
SamFares40 Must have missed that one, as I created a new file and inserted your code. Now that I used yours it doesn't work. But, when I create a new file it does (for me at least). Attached "my" file.
- SamFares40Mar 15, 2020Copper Contributor
Thanks a lot Riny_van_Eekelen