LoginSignup
0
0

More than 5 years have passed since last update.

Excelのvbaでロックしたセルを塗りつぶしてみた

Last updated at Posted at 2016-12-08
'(参照)『保護をした後にセルの塗りつぶしの色を変えたい』(くどう) 
'http://www.excel.studio-kazu.jp/kw/20050615120953.html
'Excel2013のマクロの記録で作成しました。
Sub aaa_Excelのロックしたセルを塗りつぶし()
    ActiveSheet.Unprotect
    Range("A1").Select
    Cells.Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=CELL(""protect"",A1)=1"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0.799981688894314
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
        :=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
        AllowDeletingRows:=True
    Range("A1").Select
    ActiveSheet.Protect
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0