Posted 28 November 2023, 11:35 am EST
I would like to set color following the percentages
[code]Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim i As Long
Dim max As Double ' initialize array with random data Dim count(1, 7) As Single For i = 0 To 7 count(0, i) = Rnd() * 100 count(1, i) = Rnd() * 100 Next ' initialize control fg.Cols = 3 fg.Rows = 9 fg.Cell(flexcpText, 0, 0) = "Age Range" fg.Cell(flexcpText, 0, 1) = "Females" fg.Cell(flexcpText, 0, 2) = "Males" ' make data bold fg.Cell(flexcpFontBold, 1, 1, fg.Rows - 1, fg.Cols - 1) = True ' place text in cells, keep track of maximum For i = 0 To 7 fg.Cell(flexcpText, i + 1, 0) = 10 * i & " - " & (10 * (i + 1) - 1) fg.Cell(flexcpText, i + 1, 1) = count(0, i) fg.Cell(flexcpText, i + 1, 2) = count(1, i) If count(0, i) > max Then max = count(0, i) If count(1, i) > max Then max = count(1, i) Next ' set each cell's flood percentage, ' using max to scale from 0 to -100 for column 1 ' and from 0 to 100 for column 2: For i = 0 To 7 fg.Cell(flexcpFloodPercent, i + 1, 1) = -100 * count(0, i) / max fg.Cell(flexcpFloodPercent, i + 1, 1) = -100 * count(0, i) / max fg.Cell(flexcpFloodPercent, i + 1, 2) = 100 * count(1, i) / max fg.Cell(flexcpFloodColor, i + 1, 1) = Color.Red fg.Cell(flexcpFloodColor, i + 1, 1) = Color.Yellow fg.Cell(flexcpFloodColor, i + 1, 2) = Color.Aqua Next End Sub[/code]
This is my result