PDA

View Full Version : How to bold values that are less than the average?



andersssen
03-19-2015, 09:31 PM
https://social.msdn.microsoft.com/Forums/getfile/635186
This my screenshot for this project. When I click Main Menu it will take me to my forms and one of the form will populate the textboxes with the datas of that year, when a year is selected in the listbox. Under that listbox, there is a button that will take average of that selected year and bold the values that are less than the average. I just couldn't seem to make it work, the bold code that I recorded in macro didn't work at all. Though the average works fine. I just want a specific year to be bolded and not all of the years in my worksheet. And also I'm new to VBA xD.
This is my code for that button which takes the average and bold(where the bolding part doesn't work) the values.
Private Sub btnBoldAverag_Click()
For cnt = 1 To 12
If ActiveCell.Offset(0, cnt).Value < ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-14]:RC[-3])" Then
Selection.Font.Bold = True
With Selection.Font
.Color = RandomRGBColor
.TintAndShade = 0
End With
End If
Next
ActiveCell.Offset(0, 15).Range("A1").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-14]:RC[-3])"
ActiveCell.Offset(1, 0).Range("A1").Select
End Sub