You had that code in there twice. Only 1 was commented out.

Also this line fails for me.

If max_sheet <> Replace(Int(tdy), ".", "") Then 'If there is no sheet after last thursday
I think it should be
If max_sheet <> Int(Replace(tdy, ".", "")) Then 'If there is no sheet after last thursday