title: If-else VBA statement for auto-hiding rows in Excel2010
body: <p>I am trying to hide-auto hide some rows in my Excel 2010 spreadsheet, based on a value that is entered in a specific field. I am using data validation to set the minimum and maximum number between 0 and 50. If it is 0, then hide the next 3 rows, but if it is any other number, show the rows. </p>
  
  <p>Below is the VBA code that works, except that I have to put it each possible number. Is there an IF Else statement I can use instead? If 0 then Hide, Else show the rows</p>
  
  <pre><code>If Target.Address(False, False) = "B45" Then
  
      Select Case Target.Value
  
          Case "0": Rows("46:48").Hidden = True
  
          Case "1": Rows("46:48").Hidden = False
  
          Case "2": Rows("460:48").Hidden = False
  
          Case "3": Rows("46:48").Hidden = False
  
          Case "4": Rows("46:48").Hidden = False
  
          Case "5": Rows("46:48").Hidden = False
  
          Case "6": Rows("46:48").Hidden = False
  
          Case "7": Rows("46:48").Hidden = False
  
          Case "8": Rows("46:48").Hidden = False
  
          Case "9": Rows("46:48").Hidden = False
  
          Case "10": Rows("46:48").Hidden = False
  
      End Select
  
      Else: Rows("46:48").Hidden = False
  
  End If
  </code></pre>
  
  <p>Thank you!</p>