Insert a Blank Row for visible cells only within a filter?

MixedUpExcel

Board Regular
Joined
Apr 7, 2015
Messages
222
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm having trouble running this section of code (recorded from a macro and then a variable string added as a cell reference)

Code:
' FIND LAST ROW IN COLUMN A
    With ActiveSheet
    FINALlastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With
  
' APPLY FILTER - HIDING ALL BLANKS IN COLUMN F
  
    ActiveSheet.Range("$A$1:$F$" & FINALlastrow).AutoFilter Field:=6, Criteria1:="<>"
    Rows("2:" & FINALlastrow).Select
    
' INSERT A BLANK ROW ABOVE EACH VISIBLE ROW
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

The above code has just been placed in a module.

The last line is where I am being asked to debug.

My table is something similiar to this:

Item Code
Description
Item 2
Desc 2
Qty
Top Row
IC123
DES123
IC 234
DESC234
1
TOP ROW
IC123
DES123
IC 546
DESC546
2
IC123
DES123
IC 873
DESC873
1
IC543
DES543
IC 195
DESC195
3
TOP ROW
IC543
DES543
IC 749
DESC749
1
IC943
DES943
IC 954
DESC954
2
TOP ROW
IC943
DES943
IC 864
DESC864
1
IC943
DES943
IC 753
DESC753
4
IC943
DES943
IC 951
DESC951
2

<tbody>
</tbody>

So what I need is to have a blank row inserted above all of the rows which say 'TOP ROW' in Column F.

The error message I am getting is:

Run-time error '438':
Object doesn't support this property or method
Thanks for any help with this.

Simon
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,133
Messages
6,123,234
Members
449,092
Latest member
SCleaveland

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