Necromancing.
The accepted answer didn't work for me, as the Toggle is very irregular within the column-grouping.
However, the below code worked.
You need to set background-color in the first cell as
=iif(Code.IncrementRunningValue() Mod 2 = 0, "WhiteSmoke", "White")
And in all subsequent cells as
=iif(Code.GetRunningValue() Mod 2 = 0, "WhiteSmoke", "White")
Setting it as group variable will not work, because the sorting is applied after the grouping (which means the rows are re-arranged after the values have been generated).
Private m_s_count As ULong = 0
Public Function IncrementRunningValue() As ULong
m_s_count = m_s_count + 1UL
Return m_s_count - 1UL
End Function
Public Function GetRunningValue() As ULong
Return m_s_count
End Function
Or you can do it even simpler:
Private m_s_AlternatingColor1Count As ULong = 0
Private Function ComputeAlternatingColor1(val As ULong) As String
If val Mod 2 = 0 Then
Return "WhiteSmoke"
End If
Return "White"
End Function
Public Function IncrementAlternatingColor1() As String
Dim alternatingColor As String = ComputeAlternatingColor1(m_s_AlternatingColor1Count)
m_s_AlternatingColor1Count = m_s_AlternatingColor1Count + 1UL
Return alternatingColor
End Function
Public Function GetAlternatingColor1() As String
Return ComputeAlternatingColor1(m_s_AlternatingColor1Count)
End Function
and then in the first row's background-color:
=Code.IncrementAlternatingColor1()
and all subsequent rows' background-color:
=Code.GetAlternatingColor1()
That has the advantage that you can switch the colors in ONE place (DRY).