Yes, there is. But since you haven't given much info, not much can be given back. What data are you trying to export, how much, where is it supposed to go, etc.Is there a way to do this?
Yes, there is. But since you haven't given much info, not much can be given back. What data are you trying to export, how much, where is it supposed to go, etc.
Function SendXTabToExcel()
Dim objXL As Object
Dim xlWB As Object
Dim xlWS As Object
Dim rst As DAO.Recordset
Dim lngRow As Long
Set objXL = CreateObject("Excel.Application")
With objXL
.Visible = True
Set xlWB = .Workbooks.Open("filePathAndNameHere")
Set rst = CurrentDb.OpenRecordset("Kronos")
Set xlWS = xlWB.Worksheets("Variance")
lngRow = xlWS.Range("A1").SpecialCells(xlCellTypeLastCell).Row
xlWS.Cells(lngRow, 1).CopyFromRecordset rst
xlWB.Close True
.Quit
End With
Set objXL = Nothing
End Function
Will this work if I want to code it into an On-click button command on one of my forms?
ex. Private Sub Button1_Click()
I'm looking into it now..
Try changing to this:
lngRow = xlWS.Range("A1").SpecialCells(11). Row
Okay, something like this:
Code:Function SendXTabToExcel() Dim objXL As Object Dim xlWB As Object Dim xlWS As Object Dim rst As DAO.Recordset Dim lngRow As Long Set objXL = CreateObject("Excel.Application") With objXL .Visible = True Set xlWB = .Workbooks.Open("filePathAndNameHere") Set rst = CurrentDb.OpenRecordset("Kronos") Set xlWS = xlWB.Worksheets("Variance") lngRow = xlWS.Range("A1").SpecialCells(xlCellTypeLastCell).Row xlWS.Cells(lngRow, 1).CopyFromRecordset rst xlWB.Close True .Quit End With Set objXL = Nothing End Function