Insert Blank Row Below Highlighted Cell in Bulk VBA

datamoto

New Member
Joined
Nov 12, 2021
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
I have been pulling my hair out as my data requirements are ever expanding, am currently using Marco to insert Row ABOVE coloured cells in bulk (Macro Below) which works perfectly

VBA Code:
Sub INSERTABOVE()
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = LastRow To 1 Step -1
        If Range("C" & i).Interior.Color = 65535 Then
            Rows(i).Select
            Selection.Insert Shift:=xlDown
            With Rows(i).Interior
                .Pattern = xlNone
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    Next i
    
End Sub

I want to insert a Blank Row below Coloured cell, basically the opposite of above, I run them as 2 separate processes, Can someone help me please!
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,820
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Welcome to the forum. :)

Try something like:

VBA Code:
Sub INSERTBELOW()
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = LastRow To 1 Step -1
        If Range("C" & i).Interior.Color = 65535 Then
            Rows(i + 1).Insert Shift:=xlDown
            With Rows(i + 1).Interior
                .Pattern = xlNone
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    Next i
    
End Sub
 
Solution

datamoto

New Member
Joined
Nov 12, 2021
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Welcome to the forum. :)

Try something like:

VBA Code:
Sub INSERTBELOW()
    LastRow = Range("C" & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = LastRow To 1 Step -1
        If Range("C" & i).Interior.Color = 65535 Then
            Rows(i + 1).Insert Shift:=xlDown
            With Rows(i + 1).Interior
                .Pattern = xlNone
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    Next i
   
End Sub
Will give it a go, I have 7.4 million rows to process
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,820
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
In a worksheet? That's impressive... ;)
 

datamoto

New Member
Joined
Nov 12, 2021
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
In a worksheet? That's impressive... ;)
Works a treat, very much appreciated!!!

Overall rows of data across many sheets, I'm not that insane to process all of it in one go lol!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,678
Messages
5,838,737
Members
430,566
Latest member
ChanchalSingh

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
Top