ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Don't want to insert a partial row (https://www.excelbanter.com/excel-programming/307709-dont-want-insert-partial-row.html)

Christine[_8_]

Don't want to insert a partial row
 
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



Tom Ogilvy

Don't want to insert a partial row
 
.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.

--
Regards,
Tom Ogilvy

"Christine" wrote in message
.. .
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





Tom Ogilvy

Don't want to insert a partial row
 
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.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
.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.

--
Regards,
Tom Ogilvy

"Christine" wrote in message
.. .
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







Christine[_8_]

Don't want to insert a partial row
 
Hi,

Thank you very much. It works now.

Your truly.

Christine

"Tom Ogilvy" a écrit dans le message de
...
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.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
.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.

--
Regards,
Tom Ogilvy

"Christine" wrote in message
.. .
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










All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com