how do I lock the fill color in a cell

G

Graham

Can i lock the fill color in a cell so when something is copied to that cell
it stays the locked color.

Thank You
 
G

Gary''s Student

This is an example using cell A1:

1. set the background color of cell A1
2. enter the following macro in a standard module:

Public oldcolor As Integer
Public lockcell As Range
Sub remember()
If lockcell Is Nothing Then
Set lockcell = Range("A1")
oldcolor = lockcell.Interior.ColorIndex
End If
End Sub

3. Enter this event macro in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
If lockcell Is Nothing Then Exit Sub
If Intersect(lockcell, Target) Is Nothing Then Exit Sub
lockcell.Interior.ColorIndex = oldcolor
End Sub

4. run the remember macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top