View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Myriam Myriam is offline
external usenet poster
 
Posts: 97
Default change color and protect rows

Hi, everyone! Please, I need your help!!!

I have a worksheet with dates on a1:a1096
The following code is working nicely and it changes
the appropriate cells to gray.
1) How can I extend the
"graying" to include the rows up to BQ?
2) And, also, lock those rows?
------------------------------
Private Sub ChangeColorToGray_Click()
Dim Y As Long
Worksheets(1).Unprotect
Y = (Year(Date))
With Worksheets(1).Range("a1:a1096")
Set c = .Find(Y, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Worksheets(1).Protect
End Sub
-------------------------------
As always, thanks in advance and your help is very appreciated!