clearcontents for some columns of a row

G

Guest

I have the following which will insert a copy of a row. I want to clear
columns D through AD of the inserted row and leave the other columns intact
(they have some formulas). The last statement below seems to do nothing.
InputCI is a defined row name.

Sub InsertARow(InputCI)
Range(InputCI).Offset(-2, 0).Select
Selection.Copy
Range(InputCI).Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range(InputCI).Offset(-1, 0).Select
Selection.ClearContents
End Sub
 
G

Guest

try this:

Sub InsertArow(InputCI)
Range(InputCI).Offset(-2, 0).Select
Selection.Copy
Range(InputCI).Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range(InputCI).Offset(-2, 0).Select
Selection.Cells(1, 4).Resize(1, 27).ClearContents
End Sub
 
G

Guest

That did not clear the cells.

Tom Ogilvy said:
try this:

Sub InsertArow(InputCI)
Range(InputCI).Offset(-2, 0).Select
Selection.Copy
Range(InputCI).Offset(-1, 0).Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range(InputCI).Offset(-2, 0).Select
Selection.Cells(1, 4).Resize(1, 27).ClearContents
End Sub
 
G

Guest

In contrast, it did for me. so apparently we have a different
interpretation of what InputCI actually is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top