I have an interactive table filled with over 100 different command buttons, each of which assign values to variables then use a custom function to calculate their output. They reference a table on the second sheet to get the values they assign. Is there a way to, based on whether a cell contains content or not, change the color of each button? So far, here's what I have (non-functional, of course).
Sub Auto_Open()
Dim n As Integer
n = 2
Do Until n = 114
If Sheet2.Cells(n, 4) = vbNullString Or Sheet2.Cells(n, 5) = vbNullString Or Sheet2.Cells(n, 8) = vbNullString Or Sheet2.Cells(n, 9) = vbNullString Or Sheet2.Cells(n, 10) = vbNullString Or Sheet2.Cells(n, 11) = vbNullString Then
ActiveSheet.Shapes.Range(Array("CommandButton" & (n - 1))).Select
Range.Array(Selection).BackColor = 500
Else
ActiveSheet.Shapes.Range(Array("CommandButton" & (n - 1))).Select
Range.Array(Selection).BackColor = 300
End If
n = n + 1
Loop
End Sub
EDIT: I can't explicitly state the color for each command button without having to write in over 100 different cases. I have 112 different command buttons; I'd have to write 112 seperate IF statements.