yep...copy your formula. Then go to a column that has figures all the way down all 40000 rows, press <End><Down>. This will shoot you all the way to the very bottom of that column. Now move back over to the column where your formula is. Hold down your <Shift> key, press <End><Up>. This will shoot you all the way back up to your original formula, and because you held down the <Shift> key, it will highlight all 40000 rows. Now press <Enter>. Voila!
FYI...learn to use the <END> (up/down/right/left) arrows. Once you've mastered how they work, you'll wonder how you ever got around without them.
If you're on a column/row with data, pressing <end>(somedirection) will take you to next blank cell in that column/row. Essentially excel goes to the "end" of the row/column (or until it hits a blank cell, whichever comes first).
Play around with it and you'll figure out pretty quick how it works (you can also press End/Home to get back to A1 very quickly).
FYI..you don't have to hold down the End key while you press the direction. Just press End, then press your direction. When you press End, you'll notice that in the bottom, right part of your excel status bar, it'll show the word "END". If you didn't mean to press END, press it again to cancel it.