PC Review


Reply
Thread Tools Rate Thread

Delete Macro using Offset

 
 
Alex.W
Guest
Posts: n/a
 
      9th Apr 2008
I use a message box in my macro that delivers a cell address. This aspect of
the macro work well. The following line I think is the problem:

ActiveCell.Offset(1, 0).Resize(1, 17).ClearContents

It clears the row below the one required. Is Offset the correct way to go?

AlexW
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      9th Apr 2008
The correct formula depends on what you want to do and in your example below
the 'offset' statement makes Excel select the next cell down from the active
cell and you then resize that selection to 17 cells. The 1 in the resize
statement isn't strictly necessary. If you simply want to resize from the
active cell use

ActiveCell.Resize(, 17).ClearContents

Mike

"Alex.W" wrote:

> I use a message box in my macro that delivers a cell address. This aspect of
> the macro work well. The following line I think is the problem:
>
> ActiveCell.Offset(1, 0).Resize(1, 17).ClearContents
>
> It clears the row below the one required. Is Offset the correct way to go?
>
> AlexW

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      9th Apr 2008
You want to preserve the activecell contents and delete 17 cells to the right?

ActiveCell.Offset(0, 1).Resize(1, 17).ClearContents


Gord Dibben MS Excel MVP


On Tue, 8 Apr 2008 21:01:00 -0700, Alex.W <(E-Mail Removed)>
wrote:

>I use a message box in my macro that delivers a cell address. This aspect of
>the macro work well. The following line I think is the problem:
>
>ActiveCell.Offset(1, 0).Resize(1, 17).ClearContents
>
>It clears the row below the one required. Is Offset the correct way to go?
>
>AlexW


 
Reply With Quote
 
Alex.W
Guest
Posts: n/a
 
      9th Apr 2008
Thanks Mike, it works a treat.
AlexW

"Mike H" wrote:

> The correct formula depends on what you want to do and in your example below
> the 'offset' statement makes Excel select the next cell down from the active
> cell and you then resize that selection to 17 cells. The 1 in the resize
> statement isn't strictly necessary. If you simply want to resize from the
> active cell use
>
> ActiveCell.Resize(, 17).ClearContents
>
> Mike
>
> "Alex.W" wrote:
>
> > I use a message box in my macro that delivers a cell address. This aspect of
> > the macro work well. The following line I think is the problem:
> >
> > ActiveCell.Offset(1, 0).Resize(1, 17).ClearContents
> >
> > It clears the row below the one required. Is Offset the correct way to go?
> >
> > AlexW

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and delete offset loop Karin Microsoft Excel Programming 5 16th Oct 2009 09:28 PM
Re: Macro offset using the value in a cell Don Guillett Microsoft Excel Misc 0 20th Jun 2009 04:12 PM
ActiveCell offset delete Woodi2 Microsoft Excel Programming 5 14th Mar 2009 08:08 PM
VBA Macro ActiveCell.Offset Ted Mercer Microsoft Excel Programming 2 18th Sep 2006 01:50 AM
Using Macro & offset to put in formulas miker1999 Microsoft Excel Programming 3 26th Apr 2004 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:43 PM.