Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Frmt$
If Target.Count > 1 Then Exit Sub
Frmt = "#,##0" & IIf([A1] > 0, "." & String([A1], "0"), "")
If Not Intersect(Target, Range("B1:B5")) Is Nothing Then
Target.NumberFormat = Frmt
End If
End Sub