I am new to VBA writing so bear with me here. I have been searching the web but I keep finding answers in pieces which is more confusing!
What I am trying to do is export a table from Access to Excel and run a macro (it's a formatting macro). My issue is that when Access exports the table, it resaves it and I lose the macro (The spreadsheet will be accessible to anyone so I can't just save it in the Personal workbook). When I try to copy the VBA from the macro to Access, I receive an error saying "Compile Error: Method or Data Not Found"
What I am trying to do is export a table from Access to Excel and run a macro (it's a formatting macro). My issue is that when Access exports the table, it resaves it and I lose the macro (The spreadsheet will be accessible to anyone so I can't just save it in the Personal workbook). When I try to copy the VBA from the macro to Access, I receive an error saying "Compile Error: Method or Data Not Found"
Code:
Private Sub OpenExcelExport()
Dim appExcel As Excel.Application
Dim appWB As Excel.Workbook
Set appExcel = GetObject("My Excel File")
With appExcel
.Visible = True
Columns("D:F").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Style = "Currency"
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1:A3").Select
Selection.Font.Bold = True
Range("A5:F5").Select
Selection.Font.Bold = True
Cells.Select
Cells.EntireColumn.AutoFit
Range("D5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(2, 0).Activate
Set yRng = Range("D5", Selection.Offset(1, 0))
Selection = WorksheetFunction.Sum(yRng)
Selection.Font.Bold = True
Range("E5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(2, 0).Activate
Set yRng = Range("E5", Selection.Offset(1, 0))
Selection = WorksheetFunction.Sum(yRng)
Selection.Font.Bold = True
Range("F5").Select
Selection.End(xlDown).Select
ActiveCell.Offset(2, 0).Activate
Set yRng = Range("F5", Selection.Offset(1, 0))
Selection = WorksheetFunction.Sum(yRng)
Selection.Font.Bold = True
Range("A5").Select
Cells.Select
Cells.EntireColumn.AutoFit
End Sub
Comment