I created a command button on a form. Here is the rest of the code. This code works in access but the other errors out. "Method or data member not found". It does not like .worksheet function. ....but does work in Excel.
Dim objXLS As Object
Dim wks As Object
Dim rsc As Recordset
Dim idx As Long
Set rsc = Me.RecordsetClone
rsc.MoveLast
rsc.MoveFirst
Set objXLS = CreateObject("Excel.Application")
objXLS.Workbooks.Add
Set wks = objXLS.Worksheets(1)
For idx = 0 To rsc.Fields.Count - 1
wks.Cells(1, idx + 1).Value = rsc.Fields(idx).Name
Next
wks.Range(wks.Cells(1, 1), wks.Cells(1, rsc.Fields.Count)).Font.Bold = True
wks.Range("A2").CopyFromRecordset rsc, rsc.RecordCount, rsc.Fields.Count
'Autofit columns to see entire data
wks.Range("A:M").Columns.AutoFit
'Formatting Range of Cells
wks.Range("E2:E5000").NUMBERFORMAT = "General"
wks.Range("F2:F5000").NUMBERFORMAT = "0.00"
wks.Range("G2:G5000").NUMBERFORMAT = "$#,##0.00"
wks.Range("H2:H5000").NUMBERFORMAT = "$#,##0.00"
wks.Range("I2:I5000").NUMBERFORMAT = "$#,##0.00"
wks.Range("J2:J5000").NUMBERFORMAT = "$#,##0.00"
wks.Range("K2:K5000").NUMBERFORMAT = "0%"
'Inserting a Column at Column A
wks.Range("A1").EntireColumn.Insert