-2

I am brand new to scripting so any help would be appreciated. I have searched and found some answers but still not finding a solution.

I have a simple spreadsheet called "Test", I have data validation for cell B3.

If the user inputs "No" from the drop-down box, I want the following 9 rows hidden. if the user inputs "Yes" from the drop-down box, I want the following 9 rows to show.

Like I said there are some solutions that I have search but still not producing the result that I am trying to achieve.

enter image description here

RickM
  • 1
  • 1
  • 4
    Welcome to Stack Overflow! Please review [writing the perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question) to help you to ask a good question, and thus get a good answer. Show your code for example. – Jeroen Heier Feb 27 '19 at 20:40
  • 1
    _Like I said there are some solutions that I have search but still not producing the result that I am trying to achieve._ **You need to show the code that you've tried**. How do we know what you've tried or not, what could be adapted or not, what mistakes (if any) you are making? Have you read [Google script hide rows based on cell text](https://stackoverflow.com/questions/46843299). – Tedinoz Feb 28 '19 at 13:38

1 Answers1

0

Hide and Show Rows based upon Validation Selection

You need to add the sheet name and set up the validation for B3.

function onEdit(e) {
  if(e.range.columnStart==2 && e.range.rowStart==3 && e.range.getSheet().getName()=='Sheet92') {//add your sheet name
    if(e.value=='Yes') {
      e.range.getSheet().showRows(4,9);
    }
    if(e.value=='No') {
      e.range.getSheet().hideRows(4,9);
    }
  }
}
Cooper
  • 59,616
  • 6
  • 23
  • 54