[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『VBA セルの色付けについて』(おか)
VBAのセルの色付けについて、マクロの記録を使い、条件付き書式にてグレーに設定しているはずなのに、
黒になってしまうのですが、どうすればグレーに表示されるのでしょうか。
教えてください。
< 使用 Excel:Excel2016、使用 OS:Windows10 >
現在のコードを提示してみてください (渡辺ひかる) 2019/11/22(金) 11:32
Cells.FormatConditions.Delete ' Range("$B$5:$J$500").Select Range(Selection, Selection.End(xlDown)).Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$C5=""○""" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(2).Interior .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.249946592608417 End With Selection.FormatConditions(2).StopIfTrue = False
End Sub
マクロの記録でやってみたのですが、変なところがあれば教えてください。
(おか) 2019/11/22(金) 12:50
Cells.FormatConditions.Delete ' Range("$B$5:$J$500").Select Range(Selection, Selection.End(xlDown)).Select Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$C5=""○""" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(2).Interior .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.249946592608417 End With Selection.FormatConditions(2).StopIfTrue = False End Sub
すみません、1箇所改行されていなくて、分かりづらかったので、再度掲載しました。
(おか) 2019/11/22(金) 13:05
背景色の設定は間違いないようです。
気になるのは
FormatConditions(2) です
2つ目の条件付き書式になっているようですが、
手作業で、条件付き書式を一旦クリアして、最初から設定してみてください
それでうまくいけば、再度クリアして 自動記録しながら、設定してください
(渡辺ひかる) 2019/11/22(金) 13:06
With Selection.FormatConditions(2).Interior .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.249946592608417 End With
↓
Selection.FormatConditions(2).Interior.Color = RGB(100, 100, 100)
とかでどうでしょうか? 灰色はRGB関数?で適当に作っているんですが、お気に召しますでしょうか(^^;
(虎) 2019/11/22(金) 13:32
(おか) 2019/11/22(金) 13:42
条件付き書式はいくつ設定されていますか?もし2つならルールで上にある条件が優先されますよ。 (bi) 2019/11/22(金) 13:51
条件付き書式ではなく、普通の背景色の変更で グレーにはできますか?
カラーコードがおかしいとか・・
新規ブックでも同じでしょうか?
(渡辺ひかる) 2019/11/22(金) 13:53
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.