# Selection.Insert Shift:=xlDown



## goncalo_2697 (Jan 2, 2023)

Hi, I'm trying to run the following code to add one empty line, but it only works if I run the macro as soon as I open the excel:


```
Sub LinhasAuto()
    Dim lRow As Long
Dim RepeatFactor As Variant

    lRow = 11
    Do While (Cells(lRow, "A") <> "")
          
        RepeatFactor = Cells(lRow, "AO")
        If ((RepeatFactor > 0) And IsNumeric(RepeatFactor)) Then
                  
           Range(Cells(lRow, "A"), Cells(lRow, "AT")).Copy
           Range(Cells(lRow + 1, "A"), Cells(lRow + RepeatFactor, "AT")).Select
           Selection.Insert Shift:=xlDown
             
           lRow = lRow + RepeatFactor
        End If
      
        lRow = lRow + 1
    Loop
End Sub
```


If i change anything in the file after open it up and before run the code, I get the error attached.

Thanks for your help!

Also asked here ERROR Selection.Insert Shift:=xlDown
and here Selection.Insert Shift:=xlDown


----------

