Don't want to insert a partial row

  • Thread starter Thread starter Christine
  • Start date Start date
C

Christine

Hi everyone,

I want to insert a partial row at D1:F1 if A1 <> D1 or B1 <> E1 or C1 <> F1.
I have an error 1004 and I don't know what to do with.

Sub Macro1()
Range("a1").Activate
With Range("a1")
Do Until ActiveCell.Value < 0.01
Cell_1:
If ActiveCell.Offset(0, 0) = ActiveCell.Offset(0, 3) Then
GoTo Cell_2
Else
.Range(Cells(0, 4), Cells(0, 7)).Insert Shift:=xlDown
'error 1004
ActiveCell.Offset(1, -6).Select
Cell_2:
If ActiveCell.Offset(0, 1) = ActiveCell.Offset(0, 4) Then
GoTo Cell_3
Else
.Range(Cells(0, 4), Cells(0, 7)).Insert Shift:=xlDown
'error 1004
ActiveCell.Offset(1, -6).Select
Cell_3:
If ActiveCell.Offset(0, 2) = ActiveCell.Offset(0, 5)
Then
ActiveCell.Offset(1, 0).Select
Else
.Range(Cells(0, 4), Cells(0, 7)).Insert
Shift:=xlDown 'error 1004
ActiveCell.Offset(1, -6).Select
End If
End If
End If
Loop
End With
End Sub

Thank you for you help.

Christine
 
.Range(Cells(0, 4), Cells(0, 7)).Insert Shift:=xlDown

cells must be at least Cells(1,4), Cells(1,7)

zero isn't an acceptable argument for cells.
 
Let me qualify that - cells by itself or cells qualified by a sheet object
can't accept zero as an argument since it references a non-existent range.
The other possibility is that you wanted to use cells as an offset from an
existing range. It can take a zero in that case if the range is not
Range("A1"), but the logical choice in your code for that would be the With
Range("A1"), so still would be a problem in that case.
 
Back
Top