Cómo aplicar formato condicional solamente a celdas filtradas en excel
Tengo este código pero no logro hacer que solamente me ejecute el condicional solamente a las celdas que están filtradas entre una determinada fecha:
lFecha1 = Range("N2")
lFecha2 = Range("N3")
ActiveSheet.Range("$B$11:$B$5000").AutoFilter Field:=1, Criteria1:=">=" & lFecha1, _
Operator:=xlAnd, Criteria2:="<=" & lFecha2
Range("K12:K5000").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _"=(CONTAR.SI($K:$K;K12)+CONTAR.SI($K:$K;K12))>2"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("L12:L5000").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.Color = -16776961
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.14996795556505
End With
Selection.FormatConditions(1).StopIfTrue = False
Sheets("Faltas de Almacen 946").Select
ActiveSheet.Range("I12").Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select