VBA code help when there is a new value in column insert new blank line

LNG2013

Active Member
Joined
May 23, 2011
Messages
465
I need help with some VBA code that would look at my data and when there is a new value in column B or C insert a new blank line above the new value. I also need it to ignore other blank lines and only look at new values.

Bonus points if the word NEW can be inserted in the newly created row.


So like this:

capturectb.jpg
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi,

Try:

Code:
Sub Test()
Dim rng As Range
Dim cl
Set rng = Range("C1:C100")
For Each cl In rng
    If cl.Value <> "" Then
 
        If cl.End(xlDown).Value <> cl.Value Or cl.Offset(0, 1).End(xlDown).Value <> cl.Offset(0, 1).Value Then
 
            cl.End(xlDown).EntireRow.Insert
 
        End If
 
    End If
 
Next cl
For Each cl In rng
    If cl.Value <> "" Then
 
        If cl.End(xlDown).Value <> cl.Value Or cl.Offset(0, 1).End(xlDown).Value <> cl.Offset(0, 1).Value Then
 
            Range(cl.End(xlDown).Offset(-1, 0), cl.End(xlDown).Offset(-1, 1)).Interior.ColorIndex = 6
            cl.End(xlDown).Offset(-1, 0).Value = "New"
 
 
        End If
 
    End If
 
Next cl
End Sub
 
Upvote 0

Forum statistics

Threads
1,206,761
Messages
6,074,786
Members
446,088
Latest member
Koustubh12

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top