Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Clearing Values in a Range under certain conditions

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Clearing Values in a Range under certain conditions

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Clearing Values in a Range under certain conditions

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" wrote in message
...
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
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
Clearing all values in range that aren't formulas Barb Reinhardt Excel Programming 6 October 19th 06 01:29 PM
Clearing the Values in a Drop - Down List Sagu Excel Discussion (Misc queries) 4 March 31st 06 03:32 AM
Clearing the Values in a Drop - Down List Sagu Excel Programming 2 March 31st 06 12:10 AM
Clearing Form Values the easy Way??? [email protected] Excel Programming 5 January 15th 05 07:31 AM
vba clearing out values stored in array chick-racer[_44_] Excel Programming 2 December 1st 03 09:05 PM


All times are GMT +1. The time now is 02:10 AM.

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

About Us

"It's about Microsoft Excel"