Using the worksheet_change() event. In your VBE double click the worksheet where this change (this cell) will happen. Then enter: Private Sub Worksheet_Change(ByVal Target As Range) 'Detect if the worksheet change was on cell D3 If Not (Intersect(Target, Range('D3')) Is Nothing) Then 'Hide rows if the value of D3 is 'No' Range('D4:D10').EntireRow.Hidden = (Range('D3').Value = 'No') End If End Sub Every time a change happens on this worksheet this subroutine will fire off, test if the change occured in cell 'D2' then toggle the row's hidden property based on the value. The Hidden property of the EntireRow range object takes a True or False value, so we are able to just set it equal to the result of the conditional statement (Range('D3').value = 'No') which will return a True or False greatly simplifying the amount of code you need to write. You'll just need to add more If Not (Intersect(Target, Range('whatever')) Is Nothing) Then lines to test for your other cells like D5 and hide the appropriate rows base on whatever value you are testing for in that cell.
If that gets to be too much code (testing all those intersects) you can just test the intersects once like: If Not (Intersect(Target, Union(Range('D3'), Range('D5'), Range('D8'))) Is Nothing) Then 'And then in here your individual lines that toggle the hidden property: Range('D4:D10').EntireRow.Hidden = (Range('D3').Value = 'No') Range('D6:D7').EntireRow.Hidden = (Range('D5').Value = 'No'). End If Lastly, because this beast will fire any time any change is made on this worksheet, you may want to shut off event firing while the subroutine is running.
It allows us to use the value of cell D1 for creating a dynamic VLOOKUP referring to ranges on multiple sheets. Using sheet names as variables with Indirect(). I am trying to write a VBA script on Excel 2011 For Mac and having limited success. Depending on the value in cell A1, the script needs to unhide the rows below. If A1 = 1, it needs to unhide row B. If A1 = 2, it needs to unhide rows B and C. If A1 = 3, it needs to unhide rows B, C and D.and so on, up to a maximum A1 value of 8.
But with so many options out there, no single app or website is best for everyone. Best budget planning app for mac. How to Pick the Best Personal Finance Software For You The best personal finance software is easy to use and helps you improve your money management.
You can find much more information about your privacy choices in. You always have the choice to experience our sites without personalized advertising based on your web browsing activity by visiting the, the, and/or the, from each of your browsers or devices. Best cheese sauce for mac n cheese. To avoid personalized advertising based on your mobile app activity, you can install the.