• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Calculating the occupancy rate [SOLVED]

Can you do hashed with colour to mean occupied
Hashed without colour to mean unoccupied. In both cases there will be text and possibly a comment box in them.
In the program a colour (with or without a hash) means someone has paid for the room (it is occupied) and an uncoloured cell with hash means they have asked us if we can allow for a possible, to be confirmed extension. (Room unpaid, unoccupied). It warns us to check before we book it to someone else.
If they pay for the whole period but leave early the cell is counted as occupied and it will be coloured and hashed to show us that the cabin is empty.
Thanks
 
OK, a new udf to replace old one:
Code:
Function Occupancy(myRange As Range)
For Each cll In myRange.Cells
  Select Case cll.Interior.ColorIndex
    Case xlNone, -4105, 2: zz = zz + 1
  End Select
Next cll
Occupancy = 1 - zz / myRange.Cells.Count
End Function
In your attached file to msg#22 the answers are the same as your expected results except for: Sheet2 I2 and cells Sheet5 X4:Z4, all of which you counted as occupied but according to your "Hashed without colour to mean unoccupied" should be unoccupied.
Be careful though, if you colour the hatching, but not the cell background as in this:
Capture3.JPG
it will count as unoccupied. You didn't have a cell at all with a coloured hatching in your example file.
I haven't checked about Fill effects… but I'd avoid them!
 
Thank you for your effort in this. I realize it was not easy. Also thanks for a clear explanation. This macro will speed up my processing. I had to count the cells individually before I had this. There will be no coloured hatchings.
I tested it and it works nicely.
Much appreciated!
 
Back
Top