Formula for calculating daily mining earnings I have seen other formulas, but they all vary and don't work. Can someone please show me a formula where I can plug in the difficulty and hash rate and that will give me how many bitcoin I generate in a day.

I know there are online calculators, but I want a formula for a spreadsheet.
Thank you to all replies.
Let X be hashes per second, and Y be the difficulty. Let Z be the Log base 1-1/(2^32*Y) of 1/2. Z is how many hashes it will take you to find a block, on average. Let A be the current block reward (it's currently 25). Let B be the number of seconds in a 24-hour day: 86,400. You will earn, on average, A*X*B/Z bitcoins per day.