place the codes in a regular module..
to use the codes,
from where you are calling your codes use this
Call exportXLSX("full path to the excel file", "the name of the table","the name of the sheet")
using the code below as an example
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "IH_IE History by URL Host", sFn, True, "5B_IEHist_Count"
this will be translated like this
Call exportXLSX(sFn(), "IH_IE History by URL Host","5B_IEHist_Count")