title: VBA Error 91 after correct execution with for each loop and cell comments
body: <p>I have the following code that works fine until the end of the MsgBox: </p>
  
  <pre><code>Sub CommentsAsFootnotes(myTemplate As Variant, ByRef footnotespage1 As String, ByRef footnotespage2 As String)
  Dim rngTemp As Range
  Dim rngComment As Range
  Dim footnote As String
  Dim i As Integer
  
      On Error Resume Next
      Set rngComment = myTemplate.Sheets("Seite 1 ").Range("B14:T35").SpecialCells(xlCellTypeComments)
      On Error GoTo 0
      i = 1
      'If rngComment is Nothing
          'Exit Sub
      'End If
      For Each rngTemp In rngComment
          rngTemp.value = rngTemp.value &amp; CStr(i)
          rngTemp.Characters(Start:=Len(rngTemp.value), Length:=1).Font.Superscript = True
           MsgBox rngTemp.Comment.Text
          ' error thrown here
      Next rngTemp
  
      footnotespage1 = footnote
  
  End Sub
  </code></pre>
  
  <p>The message box is shown with the correct content. 
  However, when I click "OK", an error is thrown "Error 91, Object variable or with block variable not set" and the debugger highlights the line with the message box. </p>
  
  <p>Do you have any idea what could cause this error?</p>