What's the specific error and error number you get?
I'm suspicious of the Range("AL8") myself. Do you have data in column AL?
Are you using Excel 2007?
Are you sure the error is occurring on the Sort method and not on the prior
If statement?
Are you sure that w is correctly being assigned its value?
It's only two lines of code, you can test every single expression in it.
You can go into the Immediate Window, and say ?w.Name,
?w.rows("8:50").Count, etc. to validate each expression.