jeudi 19 octobre 2017

Insert Arrow depending on If Statement in VBA

I am trying to insert an Arrow based on whether one cell number is bigger than another. The data I have is as follows.

     C         E

6  20800     20400
7  5038       6003
8  46325     46325

The if statement I have currently is as follows as I wish to add to this.

For lngI = 1 To 3
If Worksheets("Front End").Cells(lngI + 5, 3).Value > Worksheets("Front End").Cells(lngI + 5, 5).Value Then
    Worksheets("Front End").Cells(lngI + 5, 3).Interior.ColorIndex = 40
ElseIf Worksheets("Front End").Cells(lngI + 5, 3).Value < Worksheets("Front End").Cells(lngI + 5, 5).Value Then
    Worksheets("Front End").Cells(lngI + 5, 3).Interior.ColorIndex = 35
ElseIf Worksheets("Front End").Cells(lngI + 5, 3) = Worksheets("Front End").Cells(lngI + 5, 5) Then
    Worksheets("Front End").Cells(lngI + 5, 3).Interior.ColorIndex = 2
End If
Next lngI

So currently all I am doing is highlighting based on whether Cell values in Column C are larger, smaller or equal to corresponding Cell values in column E. Therefore I would like to insert a green arrow pointing upward next to the number in Cell (C,6), a red downward arrow next to the number in Cell (C,7) and a yellow sideway arrow next to the number in Cell (C,8).

Thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire