Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Clearing Unprotected Cells

What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Clearing Unprotected Cells

for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Clearing Unprotected Cells

Thanks again, Tom
-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells

(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells

(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Error on merged cells

Tom, a wrinkle - getting: Run-time error '1004': Cannot
change part of a merged cell. "If not..." line yellow.
What next?

Thanks, Phil
-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells

(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells

(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Error on merged cells

You could do it for just the first cell in the mergearea or even simpler:

cell.value = ""
instead of
cell.clearcontents



Phil Hageman wrote:

Tom, a wrinkle - getting: Run-time error '1004': Cannot
change part of a merged cell. "If not..." line yellow.
What next?

Thanks, Phil
-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells

(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells

(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls



.


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error on merged cells

for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.MergeArea.clearcontents
end if
Next

--
Regards,
Tom Ogilvy


Phil Hageman wrote in message
...
Tom, a wrinkle - getting: Run-time error '1004': Cannot
change part of a merged cell. "If not..." line yellow.
What next?

Thanks, Phil
-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells

(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells

(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this macro in
Personal.xls



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Error on merged cells

Thanks, Tom - works great. To speed things up, I took a
line from something you gave me earlier:
Application.ScreenUpdating = False/True

Thanks again.

-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.MergeArea.clearcontents
end if
Next

--
Regards,
Tom Ogilvy


Phil Hageman wrote in message
...
Tom, a wrinkle - getting: Run-time error '1004': Cannot
change part of a merged cell. "If not..." line yellow.
What next?

Thanks, Phil
-----Original Message-----
for each cell in Activesheet.UsedRange
if not cell.Locked then
cell.clearcontents
end if
Next


or assuming you wouldn't clear formulas


for each cell in Activesheet.UsedRange.SpecialCells

(xlconstants)
if not cell.Locked then
cell.clearcontents
end if
Next
' or if you would add
for each cell in Activesheet.UsedRange.SpecialCells

(xlformulas)
if not cell.Locked then
cell.clearcontents
end if
Next
--
Regards,
Tom Ogilvy

"Phil Hageman" wrote in message
...
What would the macro code be to clear all unprotected
cells in the current worksheet? Would put this

macro in
Personal.xls


.



.

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
Unprotected cells Mainer Excel Worksheet Functions 2 October 13th 09 02:37 AM
Protected/Unprotected Cells LtGator Excel Discussion (Misc queries) 0 August 10th 09 07:01 PM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
tab between unprotected cells LesaT Excel Discussion (Misc queries) 1 November 3rd 05 11:30 PM
put zero value to unprotected cells GUS Excel Programming 2 September 14th 03 10:54 PM


All times are GMT +1. The time now is 05:13 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"