1
votes

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

1
Welcome to Stack Overflow! Please review 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
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. - Tedinoz

1 Answers

0
votes

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);
    }
  }
}