Reputation: 87
I have a macro filled workbook that has worked fine for months and now when the user uses one macro I get the error (excel cannot complete this task with available resources). Once I exit out of the error I get the error (Run-time error '1004': Insert method of range class failed)
One more thing I should add. Before I received this error another user was given the error (there isn't enough memory to complete this action. Try using less data or closing other applications. to Increase memory availability, consider....)
The basis of the macro is to insert a row above row 6. I looked online but could not find a solution that helped. I don't think it's the code causing the problem because I am unable to insert a row without the use of macros.
Sub NewData()
Worksheets("Log").Rows(6).Select
Selection.Copy
Selection.Insert Shift:=xlUp
Application.CutCopyMode = False
Selection.ClearContents
Application.Worksheets("Log").Range("N6").Select
End Sub
Upvotes: 0
Views: 154
Reputation: 721
Set your range and then insert a row above it using offset(-1,0)
. Try something like this:
Sub insertaboverow()
Dim rng As Range
Set rng = Range("N6")
If Not rng.Cells(1, 1) Is Nothing Then
rng.Cells(1, 1).Offset(-1, 0).Rows.Insert
End If
End Sub
Upvotes: 0