VBA Insert blank row based on cell differences
<p>I have data in this format:
<a href="https://i.stack.imgur.com/eRfEE.png" rel="nofollow noreferrer">Excel Data</a></p>

<p>I want to add a blank row based on differences between values in column B and C.</p>

<p>I have already found a nice piece of code and it works brilliant.</p>

<pre><code>Dim i, itotalrows As Integer
Dim strRange As String

itotalrows = ActiveSheet.Range("B65536").End(xlUp).Offset(1, 0).Row


Do While i &lt;= itotalrows
    i = i + 1
    strRange = "B" &amp; i
    strRange2 = "B" &amp; i + 1
    If Range(strRange).Text &lt;&gt; Range(strRange2).Text Then
        Rows(i + 1).Insert
        itotalrows = ActiveSheet.Range("B65536").End(xlUp).Offset(1, 0).Row
        i = i + 1
    End If

Loop
</code></pre>

<p>But this checks only differences in column B. I have add the same loop for column C, but I ended up with couple of blank rows. The code I made:</p>

<pre><code>Dim i, itotalrows As Integer
Dim strRange As String

Dim n, itotalrowsc As Integer
Dim strRangec As String

itotalrows = ActiveSheet.Range("B65536").End(xlUp).Offset(1, 0).Row
itotalrowsc = ActiveSheet.Range("C65536").End(xlUp).Offset(1, 0).Row

Do While i &lt;= itotalrows
    i = i + 1
    strRange = "B" &amp; i
    strRange2 = "B" &amp; i + 1
    If Range(strRange).Text &lt;&gt; Range(strRange2).Text Then
        Rows(i + 1).Insert
        itotalrows = ActiveSheet.Range("B65536").End(xlUp).Offset(1, 0).Row
        i = i + 1
    End If

Loop

Do While n &lt;= itotalrowsc
    n = n + 1
    strRange = "C" &amp; i
    strRange2 = "C" &amp; i + 1
    If Range(strRangec).Text &lt;&gt; Range(strRangec2).Text Then
        Rows(i + 1).Insert
        itotalrows = ActiveSheet.Range("C65536").End(xlUp).Offset(1, 0).Row
        i = i + 1
    End If

Loop
</code></pre>

<p>It probably takes into consideration blank rows from the first loop and and another blank row based on that.</p>

<p>How can I tweak the code to have sth like this:</p>

<pre><code>If B[i] &lt;&gt; B[i+1] or C[i] &lt;&gt; C[i+1] Then Insert BlankRow
</code></pre>