title: How to lock multiple cells with VBA in a protected worksheet
body: <p>I need to lock multiple cells in a different protected worksheet but the same workbook after entering data by macro. Which works fine for the first data range, but it always breaks at the second range.I tried this:</p>
  
  <pre><code>ActiveWorkbook.Worksheets("Summary").Range("C3").Value = Range("B18").Value + Range("C18").Value
  ActiveWorkbook.Worksheets("Summary").Unprotect Password:="password"
  ActiveWorkbook.Worksheets("Summary").Protect Password:="password", UserInterFaceOnly:=True
  ActiveWorkbook.Worksheets("Summary").Range("A11:B15", "C3").Locked = True
  </code></pre>
  
  <p>I also tried this</p>
  
  <pre><code>ActiveWorkbook.Worksheets("Summary").Unprotect Password:="password"
  ActiveWorkbook.Worksheets("Summary").Protect Password:="password", UserInterFaceOnly:=True
  ActiveWorkbook.Worksheets("Summary").Range("A11:B15").Locked = True
  ActiveWorkbook.Worksheets("Summary").Range("C3").Value = Range("B18").Value + Range("C18").Value
  ActiveWorkbook.Worksheets("Summary").Range("C3").Locked = True
  </code></pre>
  
  <p>Each time they stop at the Range C3. For the first script, I removed ,"C3", and it is fine; for the second, I removed the whole line, it works. But i really need to lock C3 from editing. Any suggestions for how to do it?
  The Error message is always Run-time error '1004': Unable to set the locked property of the Range class.</p>