Offset Code

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

I have the following code that deletes a certain cell...

Cells(i1, "N").Delete Shift:=xlShiftUp

I would like it to also delete the next 4 cells to the
right using the same delete method? I would assume I
would have to use an offset method. Can anyone please
tell me how to do this?

Thank you


Todd Huttenstine
 
How about .resize:

cells(il,"n").resize(1,4).delete shift:=xlshiftup

or not quite as pretty:

range(cells(il,"N"),cells(il,"n").offset(0,3)).delete shift:=xlshiftup
 
I used the below method to delete the next 4 cells to the
right of Cells(i1, "N"), but there seems as though there
would be an easier way to do this. I have to put the code
for the cells I want to delete before the code to delete
the actual Cells(i1, "N") so I can use that as a reference.



Cells(i1, "N").Offset(0, 1).Delete
Shift:=xlShiftUp
Cells(i1, "N").Offset(0, 2).Delete
Shift:=xlShiftUp
Cells(i1, "N").Offset(0, 3).Delete
Shift:=xlShiftUp
Cells(i1, "N").Offset(0, 4).Delete
Shift:=xlShiftUp
Cells(i1, "N").Delete Shift:=xlShiftUp
 
Todd,

Tested it and it worked fine for me.
Dave posted the same method that I did.
He also gave you another choice which should also work.
If neither of them work for you, then there's something that
you're not telling us.

John
 
Did it not work because both John and I can't count to 4?

When I tested, it worked very similar to your code.

And it was exact if the .resize(1,4) was changed to .resize(1,5).
 
I got it to work. thanx. For some reason I forgot to add
my shift code.

Thanx to both.
 
Back
Top