exporting to excel

A

antonov

hello everybody, I know this has probably been asked many times but....
I need to export some data to a specific excel sheet situated in a specific
place. I need the data to go to the next available empty line in this sheet.
How can I do this?
thanks again for your patience
 
D

Daniel

I googled it and came across this which I thought could help you

****
Dim lngRow As Long, lngColumn As Long
Dim xlApp As Object, xlWB As Object, xlWS As Object, xlWR As Object
' next step assumes that EXCEL is not open yet
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open "Pathtofile"
Set xlWS = xlWB.Worksheets("WorksheetName")
Set xlWR = xlWS.Range("FirstCellIntoWhichYou'llWrite")
For lngRow = 0 To rst.RecordCount - 1
For lngColumn = 0 To rst.Fields.Count - 1
xlWR.Offset(lngRow, lngColumn).Value = rst.Fields(lngColumn - 1)
Next lngColumn
Next lngRow
xlWB.Save
Set xlWR = Nothing
Set xlWS = Nothing
xlWB.Close False
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
 
Top