title: Unable to delete characters from active cell in VBA
body: <p>I have an Excel 2013 worksheet that has some data that is in HTML format (in particular, subscript and superscript).  I am trying to reformat the data appropriately.  As I loop through each cell, I run a macro to format the HTML and strip out the tags. For the first cell, it works just fine.  For the second cell, I get this error: ""</p>
  
  <p>Any ideas on what is going on?</p>
  
  <p>'This cell works just fine - it turns the o character to superscript and strips out the tags</p>
  
  <pre><code>10) Using the above graphic, what is the temperature at point A?
  A. 2&lt;sup&gt;o&lt;/sup&gt; C
  B. 4&lt;sup&gt;o&lt;/sup&gt; C
  C. 5&lt;sup&gt;o&lt;/sup&gt; C
  D. 7&lt;sup&gt;o&lt;/sup&gt; C
  </code></pre>
  
  <p>'This cell throws the exception</p>
  
  <pre><code>43) Which is true for all Mesothermal (C) climates?
  A. The wamest month is between 10 and 18&lt;sup&gt;o&lt;/sup&gt;C
  B. The warmest month is greater than 10&lt;sup&gt;o&lt;/sup&gt;C and the coldest month is between 0 and 10&lt;sup&gt;o&lt;/sup&gt;C
  C. The coldest month is below 0&lt;sup&gt;o&lt;/sup&gt;C
  D. All of the above
  </code></pre>
  
  <p>Here's the macro code:</p>
  
  <pre><code>Sub FormatHTML(inval As Variant)
      Dim outval As String
      Dim isSup As Boolean
      Dim isSub As Boolean
      Dim start As Integer
      Dim start2 As Integer
  
      isSup = InStr(ActiveCell.Value, "&lt;sup&gt;") &gt; 0
      isSub = InStr(ActiveCell.Value, "&lt;sub&gt;") &gt; 0
  
      Do Until isSup = False And isSub = False
          If isSup Then
              start = InStr(ActiveCell.Value, "&lt;sup&gt;") + 5
              With ActiveCell.Characters(start:=start, Length:=1).Font
                  .Superscript = True
              End With
              With ActiveCell.Characters(start:=(start - 5), Length:=5)
                  .Delete
              End With
              start2 = InStr(ActiveCell.Value, "&lt;/sup&gt;")
              With ActiveCell.Characters(start:=start2, Length:=6)
                  .Delete
              End With
          End If
          If isSub Then
              start = InStr(ActiveCell.Value, "&lt;sub&gt;") + 5
              With ActiveCell.Characters(start:=start, Length:=1).Font
                  .Subscript = True
              End With
              With ActiveCell.Characters(start:=(start - 5), Length:=5)
                  .Delete
              End With
              start2 = InStr(ActiveCell.Value, "&lt;/sub&gt;")
              With ActiveCell.Characters(start:=start2, Length:=6)
                  .Delete
              End With
          End If
          isSup = InStr(ActiveCell.Value, "&lt;sup&gt;") &gt; 0
          isSub = InStr(ActiveCell.Value, "&lt;sub&gt;") &gt; 0
      Loop
  End Sub
  </code></pre>
  
  <p>Thanks,
  Glenn</p>