Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro: Clear contents of unlocked cells

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Macro: Clear contents of unlocked cells

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.MergeArea.clearcontents
end if
Next
End sub


"Tuckland" wrote:

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro: Clear contents of unlocked cells

Tuckland

Just a point this macro doesn't clear the content of unlocked cells. What it
does is look if the cell would be locked if the sheet was protected. i.e it
looks if the locked box is checked in Format|Cells|protection.

Mike

"Tuckland" wrote:

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro: Clear contents of unlocked cells

Instead of
r.clearcontents
try
r.value = ""



Tuckland wrote:

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro: Clear contents of unlocked cells

Thank you!

"vbapro" wrote:

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.MergeArea.clearcontents
end if
Next
End sub


"Tuckland" wrote:

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro: Clear contents of unlocked cells

Sorry for not answer you before...
I have checked the macro and as you say it doesn't cover what I really need
:-(


"Mike H" wrote:

Tuckland

Just a point this macro doesn't clear the content of unlocked cells. What it
does is look if the cell would be locked if the sheet was protected. i.e it
looks if the locked box is checked in Format|Cells|protection.

Mike

"Tuckland" wrote:

Hi everybody
I´ve just pasted the following macro and run it within my worksheet, but an
error displays as I have merged cells.

Should I consider some additional sentence for that?? (I don't know how
works VBA).

Sub rob()
For each r in activesheet.range("C7:h29").cells
if r.locked then
else
r.clearcontents
end if
Next
End sub

Thank you in advance


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
Macro to clear contents of certain cells MrAcquire Excel Discussion (Misc queries) 3 February 11th 10 06:25 PM
clear unlocked cells macro help please CandiC Excel Worksheet Functions 3 November 14th 09 12:37 AM
Delete contents unlocked cells RobN[_3_] Excel Discussion (Misc queries) 9 December 13th 07 11:34 PM
Macro to clear contents of unprotected cells AND drop down boxes JB2010 Excel Discussion (Misc queries) 3 March 30th 06 10:13 AM
Selecting only unlocked cells to clear RAP Excel Programming 5 August 18th 05 02:55 AM


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