title: Lock all the cells of a worksheet when specified text entered
body: <p>I have an Excel sheet which has fields to enter data.</p>
  
  <p>Let's say the total fields is 20. Ten of them are locked by default whenever the user opens the workbook. Now, one of the fields is asking the user to enter a password. If the password was "AAA", then  five fields (of the ten locked ones) will be unlocked . If the user inputs a password as "BBB", then all the cells of the worksheet will be read-only and locked.</p>
  
  <p>I am focusing on the case when the user inputs "BBB". I tried this code:</p>
  
  <pre><code>if Range("Password").value="BBB" then
   cells.select
   selection.locked=true
  end if
  </code></pre>
  
  <p>It gives me an error as " Overflow".</p>