VBA (CODE INCLUDED) Need help Inserting Row Below Selection not Above

LNG2013

Active Member
Joined
May 23, 2011
Messages
465
Hello,

I have code below, that currently targets and inserts a blank row above whatever I have set to Autofiltered.
In this case I have already manually set the Autofilter.

Instead of ABOVE what it Autofiltered, I was wondering if there is a way to insert a row BELOW what is Autofiltered.


Code:
Sub InsRws()
' *This code assumes Autofilter is already applied

Dim Rng As Range

Set Rng = Intersect(Columns(1), ActiveSheet.UsedRange).SpecialCells(xlCellTypeVisible)
Range("A1").AutoFilter
Rng.EntireRow.Insert
Range("A1").Select

' *Delete Excess Header blank row created by code

Rows("1:1").Select
Selection.Delete Shift:=xlUp

' *Insert Blank Line in row 2 for empty selection

Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

End Sub

Example with Filters Applied:

A (Filtered by Date)B (Filtered by Type)C
DateFruitPrice
1/15/2019Apple.99
1/15/2019Banana.50
1/15/2019Clementine.25

<tbody>
</tbody>

Example After Code Run: This example negates other data that might exist after Autofilter is turned off.

A (Filtered by Date)B (Filtered by Type)C
DateFruitPrice
1/15/2019Apple.99
1/15/2019Banana.50
1/15/2019Clementine.25

<tbody>
</tbody>


Desired Effect: Lines inserted below what is Autofiltered instead of above.

A (Filtered by Date)B (Filtered by Type)C
DateFruitPrice
1/15/2019Apple.99
1/15/2019Banana.50
1/15/2019Clementine.25

<tbody>
</tbody>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try adding this
Code:
Rng[COLOR=#ff0000].Offset(1)[/COLOR].EntireRow.Insert
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

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