Hello,
I do have an access form called T4, which is exported to an excel file, where i do have complex formulas and calculations.
I would some assistance in exporting the table to excel. I cannot re-write the excel file every time the form is edited. When i execute the macro to export them to excel, it gives an error.
Here is the code:
Any help is appreciated. Thanks in advance.
I do have an access form called T4, which is exported to an excel file, where i do have complex formulas and calculations.
I would some assistance in exporting the table to excel. I cannot re-write the excel file every time the form is edited. When i execute the macro to export them to excel, it gives an error.
Here is the code:
Code:
Option Compare Database
Function MacroT4()
Dim xlApp As Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
Dim acRng As Variant
Dim xlRow As Integer
Dim rst As Recordset
Set xlApp = New Excel.Application
Set xlWB = xlApp.Workbooks.Open("C:\Desktop\TAX\Slips.xls")
Set xlWS = xlWB.Worksheets("T4A")
xlRow = (xlWS.Columns("A").End(xlDown).Row)
Set rst = Form.OpenRecordset
Dim c As Integer
c = 1
xlRow = 3
Do Until rst.EOF
For Each acRng In rst.Fields
xlWS.Cells(xlRow, c).Formula = acRng
c = c + 1
Next acRng
xlRow = 3
c = 1
rst.MoveNext
If xlRow > 10 Then GoTo rq_Exit
Loop
rq_Exit:
rst.Close
Set rst = Nothing
Set xlWS = Nothing
xlWB.Close acSaveYes
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
Exit Function
End Function
Any help is appreciated. Thanks in advance.
Comment