title: macro for Hide rows in excel 2010
body: <p>I'm kinda new to programming in VBA. I read some stuff on the internet but I couldnt find what I need or couldnt get it working. My problem:</p>
  <p>in worksheet 'sheet 1' in cell B6 a value is given for how many years a project will be exploited.</p>
  <p>in worksheets 'sheet 2' and 'sheet 3' i made a spreadsheet for 50 years ( year 1 to year 50; row 7 to row 56).</p>
  <p>in cell b6 in 'sheet 1' i want to enter a value between 1 and 50. when the value is 49 i want to hide row 56 in 'sheet2' and 'sheet 3'. when the value is 48 i want to hide rows 55:56 in 'sheet2' and 'sheet 3', and so on.
  this is what i got so far but i cant get it to work automaticly when i change the value in cell B6:</p>
  <pre><code>Sub test1()
      If Range(&quot;sheet1!B6&quot;) = 50 Then
      Rows(&quot;52:55&quot;).EntireRow.Hidden = False
      Else
      If Range(&quot;sheet1!B6&quot;) = 49 Then
      Rows(&quot;55&quot;).EntireRow.Hidden = True
      Else
      If Range(&quot;sheet1!B6&quot;) = 48 Then
      Rows(&quot;54:55&quot;).EntireRow.Hidden = True
      
      End If: End If: End If:
      
      End Sub
  </code></pre>
  <p>i hope someone can help me with my problem.</p>
  <p>Thank you</p>