Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 279
Default clear contents cells of unprotected cells

Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute cell
reference for each of the unprotected cells I want to clear?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default clear contents cells of unprotected cells

Something like:

Sub Test()
Dim c As Range
For Each c In ActiveSheet.UsedRange.Cells
If Not c.Locked Then c.ClearContents
Next
End Sub

--

Vasant

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default clear contents cells of unprotected cells

for each cell in activesheet.UsedRange
if cell.locked = false then
cell.Clearcontents
end if
Next

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?



  #4   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 279
Default clear contents cells of unprotected cells

Thanks, it worked!

"Vasant Nanavati" wrote:

Something like:

Sub Test()
Dim c As Range
For Each c In ActiveSheet.UsedRange.Cells
If Not c.Locked Then c.ClearContents
Next
End Sub

--

Vasant

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?




  #5   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 279
Default clear contents cells of unprotected cells

Thanks, that did it!

"Tom Ogilvy" wrote:

for each cell in activesheet.UsedRange
if cell.locked = false then
cell.Clearcontents
end if
Next

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default clear contents cells of unprotected cells

Tom,

I've implemented the code you supplied for Ed, however, some of the cells
involved are merged and Error 1004 appears and says "Cannot change part of a
merged cell". Any ideas?

Thanks in advance!

"Tom Ogilvy" wrote:

for each cell in activesheet.UsedRange
if cell.locked = false then
cell.Clearcontents
end if
Next

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default clear contents cells of unprotected cells

change:

cell.Clearcontents
to
cell.value = ""



RemySS wrote:

Tom,

I've implemented the code you supplied for Ed, however, some of the cells
involved are merged and Error 1004 appears and says "Cannot change part of a
merged cell". Any ideas?

Thanks in advance!

"Tom Ogilvy" wrote:

for each cell in activesheet.UsedRange
if cell.locked = false then
cell.Clearcontents
end if
Next

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
Hi. I am trying to clear the contents of all unprotected cells only on a
protected worksheet. Any ideas how to do it without giving the absolute

cell
reference for each of the unprotected cells I want to clear?





--

Dave Peterson
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
Clear Contents Of Cells Where Value = 0 carl Excel Worksheet Functions 3 July 6th 07 06:02 PM
Macro to clear contents of unprotected cells AND drop down boxes JB2010 Excel Discussion (Misc queries) 3 March 30th 06 10:13 AM
How do I delete the contents of unprotected cells only? Dan Excel Discussion (Misc queries) 3 August 8th 05 08:18 PM
Clear Contents - NonBold cells Steve Excel Discussion (Misc queries) 3 February 13th 05 11:36 PM
Delete contents of unprotected cells in workbook BD7447 Excel Worksheet Functions 1 November 6th 04 05:41 PM


All times are GMT +1. The time now is 02:24 PM.

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"