Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Set cell color

Sub Set_Protection()     On Error GoTo errorHandler     Dim myDoc As Worksheet     Dim cel As Range     Set myDoc = ActiveSheet     myDoc.Unprotect     For Each cel In myDoc.UsedRange         cel.Locked = True         cel.Font.ColorIndex = xlColorIndexAutomatic     Next     myDoc.Protect     Exit Sub     errorHandler:     MsgBox Error End Sub