View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
icystorm icystorm is offline
external usenet poster
 
Posts: 20
Default "Run-time error '1004'

Greetings:

In Excel 2007, I wrote a macro to insert a line between all visible
rows. However, one portion of the code fails and I am unable to
isolate the reason.

The specific error is:

Microsoft Visual Basic "Run-time error '1004':
Insert method of Range class failed

The section of the following code that fails is
"Selection.EntireRow.Insert". Any suggestions would be appreciated.
Thank you.

' select range for unique filter and insert rows

Range("A1").Select
Application.CutCopyMode = False
Range("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
ActiveSheet.ShowAllData