title: Interesting problem with VBA error 91, protection and intersetcion
body: <p>Please, could anyone help with error 91, I can't find a solution. Firstly the related code part:</p>
  <pre><code>.......
  Application.EnableEvents = False 
  PrUpr.UJournal 'Protection code for sheet is located in  PrUpr module.
  Intersect(targetRow, rgRecName) = foundName '!! Here the problem comes out !!
  .......
  PrUpr.PJournal
  .......
  </code></pre>
  <p>Where <code>PrUpr.UJournal</code> contains many subs including:</p>
  <pre><code>Sub UJournal()
   ThisWorkbook.Worksheets(&quot;Journal&quot;).Unprotect &quot;123&quot;
  End Sub
  </code></pre>
  <p>The protection was activated with the code:</p>
  <pre><code>Sub PJournal()
   With ThisWorkbook.Worksheets(&quot;Journal&quot;)
     .Protect Password:=&quot;123&quot;, UserInterfaceOnly:=True, AllowFormattingCells:=True, 
      AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowSorting:=False, 
      AllowFiltering:=True, AllowDeletingRows:=True
     .EnableSelection = xlNoRestrictions
   End With
  End Sub
  </code></pre>
  <p><code>targetRow (entire row range), rgRecName(column range) And  foundName(string)</code>  All contain readable values, however <code>Intersect(targetRow, rgRecName)</code> value is nothing.</p>
  <p>The code works under the event  <code>Worksheet_Change(ByVal Target As Range)</code>, everything works fine until I turn on the protection of the sheet with a macro and then try to unprotect it. No <code>ActiveSheet</code> and commands like this is used in the code. The code always works when I use debug mode step by (F8) from the beginning, but when it works automatically it throws an error. <code>Wait</code> doesn't help either. If the code starts working with an unprotected sheet, then everything works fine until protection is enabled by code (or manually). <code>UserInterfaceOnly:=True / False</code> unfortunately has no effect. <code>Workbook_Open</code> doesn't contains protection-related objects Setting the whole sheet cells parameter to locked or unlocked does nothing. Two userforms are open while the code is running.
  Maybe someone has faced such a problem?</p>