From the discussion going on if the problem is not solved with the help of the formula, and then you can solve the problem by using the code. The code is as follows:
Code:
Option Explicit
Private Sub Workbook_Open()
Sheet1.RemoveHs
End Sub
Option Explicit
Dim SC As Long
Dim Lc, Tc As Long
Dim Grade, i As Long
Dim H, H1, H2, H3, H4, H5 As Shape
Private Sub Worksheet_Activate()
[B:B].Font.ColorIndex = 2
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet
If Target.Column > 1 Then
RemoveHs
Exit Sub
End If
If Target.Count > 1 Then
RemoveHs
Exit Sub
End If
If Target.Value = "" Then
RemoveHs
Exit Sub
End If
Lc = Target.Offset(0, 1).Left
Tc = Target.Offset(0, 1).Top
SC = Shapes.Count
If SC > 0 Then
RemoveHs
AddHs
Else
AddHs
End If
End With
End Sub
Sub RemoveHs()
With ActiveSheet
SC = Shapes.Count
If SC > 0 Then
Shapes.SelectAll
Selection.Delete
End If
End With
End Sub
Sub AddHs()
With ActiveSheet
Set H1 = Shapes.AddShape(msoShape5pointH, Lc, Tc, 10,
10)
H1.Name = "H1"
H1.OnAction = "Sheet1.ClickH1"
Set H2 = Shapes.AddShape(msoShape5pointH, Lc + 12, Tc,
10, 10)
H2.Name = "H2"
H2.OnAction = "Sheet1.ClickH2"
Set H3 = Shapes.AddShape(msoShape5pointH, Lc + 24, Tc,
10, 10)
H3.Name = "H3"
H3.OnAction = "Sheet1.ClickH3"
Set H4 = Shapes.AddShape(msoShape5pointH, Lc + 36, Tc,
10, 10)
H4.Name = "H4"
H4.OnAction = "Sheet1.ClickH4"
Set H5 = Shapes.AddShape(msoShape5pointH, Lc + 48, Tc,
10, 10)
H5.Name = "H5"
H5.OnAction = "Sheet1.ClickH5"
End With
ColouredHs
End Sub
Sub ColouredHs()
Grade = ActiveCell.Offset(0, 1).Value
For Each H In ActiveSheet.Shapes
i = Right(H.Name, 1)
If i <= Grade Then
H.Fill.PresetGradient msoGradientDiagonalUp, 1,
msoGradientGold
End If
Next H
End Sub
Sub ClearHs()
For Each H In ActiveSheet.Shapes
H.Fill.Solid
H.Fill.ForeColor.SchemeColor = 9
Next H
ColouredHs
End Sub
Sub ClickH1()
ActiveCell.Offset(0, 1).Value = 1
ClearHs
End Sub
Sub ClickH2()
ActiveCell.Offset(0, 1).Value = 2
ClearHs
End Sub
Sub ClickH3()
ActiveCell.Offset(0, 1).Value = 3
ClearHs
End Sub
Sub ClickH4()
ActiveCell.Offset(0, 1).Value = 4
ClearHs
End Sub
Sub ClickH5()
ActiveCell.Offset(0, 1).Value = 5
ClearHs
End Sub
Bookmarks