mercredi 27 octobre 2021

Change Row Color in Excel Range if condition is met in vb.Net

In range "A" to "H" I want to change color when condition in H cell is met. My code work, but it change entire row color if I use this one:

    For Each h In shXL.Range("A2:H150").Columns(8).Cells
                If h.Value > 14 Then
                    h.EntireRow.Interior.Color = Color.FromArgb(251, 254, 138)
                End If
    Next

Or color changed with shift from H to N, when I use this one:

For Each h In shXL.Range("A2:H150").Columns(8).Cells
            If h.Value > 14 Then
                h.Range("A1:H1").Interior.Color = Color.FromArgb(251, 254, 138)
            End If
Next

How to do it?

Aucun commentaire:

Enregistrer un commentaire