Tom, thanks for the syntax. I adjusted it to exclude row one which includes headers, but nothing drops in the Excel spreadsheet cell, so I hard coded the referenced cells; again nothing? What am I missing? I have included the entire code module up to your aditional line as modified per comments above. Any thoughts
Look forward to your feed-back as you recognized my need for the XIRR function
Thanks
Forres
Private Sub Command0_Click(
Dim cnt As New ADODB.Connectio
Dim rst As New ADODB.Recordse
Dim xlApp As Object ' Excel applicatio
Dim xlWb As Object ' Excel workboo
Dim xlWs As Object ' Excel workshee
Dim strDB As Strin
Dim fldCount As Intege
Dim recCount As Lon
Dim iCol As Integer 'Index variable for the current colum
Dim iRow As Integer 'Index variable for the current ro
strDB = "c:\FundSectors2002.mdb
'Open connection to the databas
cnt.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &
"Data Source=" & strDB & ";
'Open recordset based on CashFlow1 tabl
rst.Open "Select CashFlow1.Date, CashFlow1.Transaction, CashFlow1.Amount From CashFlow1", cn
'Open or create an instance of Excel and add a workboo
On Error Resume Nex
Set xlApp = GetObject(, "Excel.Application")
If Err.Number <> 0 The
Err.Clear ' Clear Err object in case error occurred
Set xlApp = CreateObject("Excel.Application")
End I
Set xlWb = xlApp.Workbooks.Ad
Set xlWs = xlWb.Worksheets("Sheet1"
'Display Excel and give user control of Excel's lifetim
xlApp.Visible = Tru
xlApp.UserControl = Tru
'Copy field names to the first row of the workshee
fldCount = rst.Fields.Coun
For iCol = 1 To fldCoun
xlWs.Cells(1, iCol).Value = rst.Fields(iCol - 1).Nam
Nex
'Copy the recordset to the worksheet, starting in cell A
xlWs.Cells(2, 1).CopyFromRecordset rs
'recCount = rst.RecordCount 'Attempt to capture record count and use as variable instead of End property
xlWs.Range("c1").End(xlDown).Offset(1, 0).Select 'Selects c7, blank cell at bottom of contiguous colum
xlWs.Selection.FormulaR1C1 = "=XIRR(R2C:R[-1]C,R2C1:R[-1]C1,0.1)" 'Tom's line modifie
xlWs.Selection.FormulaR1C1 = "=XIRR(C2:C7,A2:A7,0.1)" 'Hard coded cell references