The first range is actually E30:CV30. The total will go in DE30. If it calculates as a function, that’s where it will be. Four separate ranges in total, all identical in length, and fixed. The red line is a red border from the Font tab in the ribbon. Always the same color, thickness and style. It ends up looking like a very thin horizontal bar graph. There is no Conditional Formatting in any cell in the ranges.
Private Sub CommandButton1_Click()
Dim c As Range
Dim x As Long
For Each c In Range("E30:CV30")
x = x - (c.DisplayFormat.Borders(xlTop).Color = vbRed)
Next c
Range("DD30").Value = x / 4
End Sub
This one works close for what I thought I wanted. Two things. First, I now find it will work better as a Worksheet_Change, but when I do this:
Private Sub Worksheet_Change(ByVal Target as Range)
It crashes Excel.
Second, the code only works if the 4 outside borders are all red. If it's just the top one, It doesn't count it.
I made a simplified version to illustrate.
We are using this to draw a single line
If we use the exact same option but expand it to all outside borders, it works. Just a single border, it doesn't.