Unlock cells based on colour

  • Thread starter Thread starter violasrbest
  • Start date Start date
V

violasrbest

Hi

I have input cells coloured blue and I want to unlock these cells. I know I
need to use Colorindex, but I can't work out how to put it all together.

Many thanks
 
Here's a procedure that will change your 'Blue' cells to unprotected.
HOWEVER, you need to decide which blue you want to unprotect. I've also
attached a UDF [ColorOfCell] that will tell you the # associated with the
BLUE you want. Change the 'BlueColor' variable in the procedure to that #.

'/============================/
Public Sub MakeBlueCellsUnProtected()
Dim BlueColor As Long
Dim rngCell As Range

BlueColor = 16711680 'YOUR color Blue

For Each rngCell In Application.ActiveSheet.UsedRange
If rngCell.Interior.Color = BlueColor Then
rngCell.Locked = False
End If
Next rngCell

End Sub
'/============================/
Function ColorOfCell(Select_Cell As Range)
'Color of Background in a cell
'Full numberic equivalent of color
Application.Volatile True
ColorOfCell = Select_Cell.Interior.Color
End Function
'/============================/
 
Thanks Gary, great help

Gary Brown said:
Here's a procedure that will change your 'Blue' cells to unprotected.
HOWEVER, you need to decide which blue you want to unprotect. I've also
attached a UDF [ColorOfCell] that will tell you the # associated with the
BLUE you want. Change the 'BlueColor' variable in the procedure to that #.

'/============================/
Public Sub MakeBlueCellsUnProtected()
Dim BlueColor As Long
Dim rngCell As Range

BlueColor = 16711680 'YOUR color Blue

For Each rngCell In Application.ActiveSheet.UsedRange
If rngCell.Interior.Color = BlueColor Then
rngCell.Locked = False
End If
Next rngCell

End Sub
'/============================/
Function ColorOfCell(Select_Cell As Range)
'Color of Background in a cell
'Full numberic equivalent of color
Application.Volatile True
ColorOfCell = Select_Cell.Interior.Color
End Function
'/============================/




--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



violasrbest said:
Hi

I have input cells coloured blue and I want to unlock these cells. I know I
need to use Colorindex, but I can't work out how to put it all together.

Many thanks
 
Back
Top