Code Snippets → Export A Table Or Query To Excel – Specific Worksheet on Specific Workbook

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.