L
Lawrence Mak
I was working on a function that calculates the average
value of a range of cells. If the average amounts to
zero, I want to change either the cell background to a
particular color to alert users. I tried this in VBA:
If Occupancy = 0 Then
ActiveCell.Interior.Color= RGB(255, 0, 0)
End If
Where Occupancy is the name of the function. However this
doesn't work as expected and the cell's color remains
unchanged. Yet the same command works perfectly through
the immediate window. Can anyone explain why it doesn't
work and how to rectify it? Thanks
value of a range of cells. If the average amounts to
zero, I want to change either the cell background to a
particular color to alert users. I tried this in VBA:
If Occupancy = 0 Then
ActiveCell.Interior.Color= RGB(255, 0, 0)
End If
Where Occupancy is the name of the function. However this
doesn't work as expected and the cell's color remains
unchanged. Yet the same command works perfectly through
the immediate window. Can anyone explain why it doesn't
work and how to rectify it? Thanks