View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default Assign and clear value to unlocked cells in a protected sheet

On Fri, 1 Aug 2008 08:55:00 -0700, Ram B
wrote:

I want to create two buttons, one that will give the unlocked cells in a
range H12:H400 the text "Gray" and the other will clear the contents. Any
help will be appriciated.


Sub MarkGrey()

Dim rCell As Range

For Each rCell In Sheet1.UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub

Make a new sub and change the line to clearcontents for the button to clear.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com