ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   clear contents cells of unprotected cells (https://www.excelbanter.com/excel-programming/331224-clear-contents-cells-unprotected-cells.html)

Ed

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?

Vasant Nanavati

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?




Tom Ogilvy

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?




Ed

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?





Ed

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?





RemySS

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?





Dave Peterson

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


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com