#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Offset Code

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Offset Code

Todd,

Try:

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

John

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Offset Code

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)).del ete shift:=xlshiftup


Todd Huttenstine wrote:

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


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Offset Code

That did not work.


-----Original Message-----
Todd,

Try:

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

John

"Todd Huttenstine"

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



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Offset Code

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



-----Original Message-----
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
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Offset Code

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


"Todd Huttenstine" wrote in message
...
That did not work.


-----Original Message-----
Todd,

Try:

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

John

"Todd Huttenstine"

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



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Offset Code

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).



Todd Huttenstine wrote:

That did not work.

-----Original Message-----
Todd,

Try:

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

John

"Todd Huttenstine"

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



.


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Offset Code

I got it to work. thanx. For some reason I forgot to add
my shift code.

Thanx to both.


-----Original Message-----
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


"Todd Huttenstine"

wrote in message
...
That did not work.


-----Original Message-----
Todd,

Try:

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

John

"Todd Huttenstine"


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


.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Offset code for dynamic row# & multiple columns in LINEST function RJ Excel Worksheet Functions 3 May 29th 07 06:29 PM


All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"