|
こんにちは。
初心者ですがお願いします
どなたか教えてください
条件付書式設定の内容を変更したくてマクロを書いていましたが、
あまりにも長すぎて困っていますたすけてください。
セル一個を参照し1があれば色塗りで
色塗りセルは、縦に13回横に70回ほどあります
参照セルは、縦に30回横に13回です
Sub Macro2()
Range("C106").Select <--------色塗りセル
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DB$4=1" <-参照セル
Selection.FormatConditions(1).Interior.ColorIndex = 38 <--色です
Range("C105").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DB$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C104").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DC$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C103").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DC$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C102").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DD$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C101").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DD$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C100").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DE$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C99").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DE$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C98").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DF$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C97").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DF$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C96").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DG$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C95").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DG$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C94").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DH$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C93").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DH$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C92").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DI$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C91").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DI$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C90").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DJ$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C89").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DJ$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C88").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DK$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C87").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DK$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C86").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DL$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C85").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DL$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C84").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DM$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C83").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DM$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C82").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DN$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("C81").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DN$4=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("D106").Select <--ここから2行目のセルに対して処理をしています。
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DB$5=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("D105").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DB$5=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("D104").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DC$5=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("D103").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DC$5=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
Range("D102").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$DD$5=1"
Selection.FormatConditions(1).Interior.ColorIndex = 38
End Sub
|
|