Hi,
l want to do conditional formatting rule with macro for multiple sequences.
Example
Formula=EĞER($S$25=0;1) Target Practice=$C$25:$N$47
Formula=EĞER($S$26=0;1) Target Practice=$C$48:$N$70
Formula=EĞER($S$27=0;1) Target Practice=$C$71:$N$93
Formula=EĞER($S$28=0;1) Target Practice=$C$94:$N$116
...
...
Formula=EĞER($S$124=0;1) Target Practice=$C$2302:$N$2324
If "S25" is equal to "0" or blank cells; C25: N47 in the block, text and background (fill) "white" color, borders the "No" I want to do.
If "S25" is not equal to "0" or full, C25: N47 in the block will return back.
I tried to write the code but did not.
Sub Makro1()
'
' Makro1 Makro
'
'
Range("C25:N47").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=EĞER($S$25=0;1)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).Borders(xlLeft).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlTop).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlBottom).LineStyle = xlNone
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
ActiveWindow.SmallScroll Down:=18
Range("C48:N70").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=EĞER($S$26=0;1)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).Borders(xlLeft).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlTop).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlBottom).LineStyle = xlNone
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
ActiveWindow.SmallScroll Down:=15
Range("C71:N93").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=EĞER($S$27=0;1)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
Selection.FormatConditions(1).Borders(xlLeft).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlRight).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlTop).LineStyle = xlNone
Selection.FormatConditions(1).Borders(xlBottom).LineStyle = xlNone
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
End With
Selection.FormatConditions(1).StopIfTrue = True
End Sub
or
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tr, ilk, son As Integer
tr = Target.Row - 24
ilk = tr * 23 + 2
son = ilk + 22
If Target.Column = 19 Then
If Target.Value = "" Or Target.Value = 0 Then
' If the cell is empty
Range("C" & ilk & ":N" & son).Borders(xlLeft).LineStyle = xlNone
Range("C" & ilk & ":N" & son).Borders(xlRight).LineStyle = xlNone
Range("C" & ilk & ":N" & son).Borders(xlTop).LineStyle = xlNone
Range("C" & ilk & ":N" & son).Borders(xlBottom).LineStyle = xlNone
Else
'If the cell is full
Range("C" & ilk & ":N" & son).Borders(xlLeft).LineStyle = xlAutomatic
Range("C" & ilk & ":N" & son).Borders(xlRight).LineStyle = xlAutomatic
Range("C" & ilk & ":N" & son).Borders(xlTop).LineStyle = xlAutomatic
Range("C" & ilk & ":N" & son).Borders(xlBottom).LineStyle = xlAutomatic
End If
End If
End Sub
Sorry my bad English.
Thanks for your helping.
Bookmarks