为什么不更新“ALT”(用于确定行颜色的变量)(见图)
这是代码:
Private Alt As Boolean
Private cnt as integer
Function Stripe(ByVal NewRow As Boolean, ByVal OddColor as String, ByVal EvenColor as String) As String
If NewRow Then
Alt = Not Alt ' Trip the switch denoting a new row
cnt = cnt + 1
end if
If Alt Then
Return OddColor
Else
Return EvenColor
End If
End Function
Function getalt () as boolean
return alt
end function
function getcnt() as integer
return cnt
end function
这是“背景颜色”第一列中的代码:
=Code.Stripe(true, "#E7E7E7", "Transparent")
第二到N列:
=Code.Stripe(False, "#E7E7E7", "Transparent")
注意,您可能需要在另一个窗口中打开图像才能查看调试输出 - 我正在使用 getalt 和 getcnt 显示“cnt”和“alt”的值