Code Snippets → Export Table/Query To Excel to New Named Sheet

Copy this code into a standard (not form or report) module. Name the module something other than this function name and make sure to set a reference to DAO if you don’t already have one.