Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Hi, I'm trying to highlight some rows using VBA, and for some reason it doesn't grab the last row, and it grabs the first column

$
0
0

ask mentioned in the title, I am trying to highlight some rows using VBA. Well parts of my data get highlighted, but my last row and my first column "A" get highlighted.

enter image description here

''Carton Audit Format Control
'

    Range("B16:V1000").FormatConditions.Delete
    Range("$B16:$V100").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AND($P16=0,$B176>0)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent6
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False

    Range("$B16:$V100").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$F17>$P17"
    Selection.FormatConditions(Selection.FormatConditions.Count).Priority = 2
    With Selection.FormatConditions(2).Interior
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
    End With
    Selection.FormatConditions(2).StopIfTrue = False

    Range("$B16:$V100").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$F17<$P17"
    Selection.FormatConditions(Selection.FormatConditions.Count).Priority = 3
    With Selection.FormatConditions(3).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.599993896298105
    End With
    Selection.FormatConditions(3).StopIfTrue = False


End Sub

Anything helps. Thanks so much!


Viewing all articles
Browse latest Browse all 88066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>