PC Review


Reply
Thread Tools Rate Thread

Clearing Values in a Range under certain conditions

 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      8th Nov 2006
I'd like to clear values from myRange under either of the following conditions

If the cell doesn't contain a formula OR if the cell is locked.

I have the following CODE

For Each r In myRange
Debug.Print r.Row, r.Formula, r.locked

If r.Formula = No Then
r.ClearContents
End If
Next r

I see that r.formula returns No when there is a formula and r.locked returns
True or False.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      8th Nov 2006
I figured it out. I forgot to remove a more global clearcontents line.

"Barb Reinhardt" wrote:

> I'd like to clear values from myRange under either of the following conditions
>
> If the cell doesn't contain a formula OR if the cell is locked.
>
> I have the following CODE
>
> For Each r In myRange
> Debug.Print r.Row, r.Formula, r.locked
>
> If r.Formula = No Then
> r.ClearContents
> End If
> Next r
>
> I see that r.formula returns No when there is a formula and r.locked returns
> True or False.

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      8th Nov 2006
For Each r In myRange
If Not r.HasFormula Or r.Locked Then
r.ClearContents
End If
Next r


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Barb Reinhardt" <(E-Mail Removed)> wrote in message
news:CC2DA340-94C3-4D79-BB32-(E-Mail Removed)...
> I'd like to clear values from myRange under either of the following

conditions
>
> If the cell doesn't contain a formula OR if the cell is locked.
>
> I have the following CODE
>
> For Each r In myRange
> Debug.Print r.Row, r.Formula, r.locked
>
> If r.Formula = No Then
> r.ClearContents
> End If
> Next r
>
> I see that r.formula returns No when there is a formula and r.locked

returns
> True or False.



 
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
clearing values of cells in named range(s) so the cells are empty BRC Microsoft Excel Programming 1 10th Jan 2010 06:54 AM
SUMPRODUCT or SUMIF if any values in a range equal any values in another range PCLIVE Microsoft Excel Worksheet Functions 3 15th Jul 2009 07:43 PM
Clearing all values in range that aren't formulas =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 6 19th Oct 2006 01:29 PM
How to calculate values in multiple values with multi conditions =?Utf-8?B?Q3VydGlz?= Microsoft Excel Worksheet Functions 2 15th Jul 2005 02:36 AM
Backing Up and Clearing Event Logs If the Log Meets Specific Conditions james Microsoft Windows 2000 File System 1 12th Jul 2003 02:15 PM


Features
 

Advertising
 

Newsgroups
 


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