I have a LotusScript formula that searches for specific documents within a Db, resulting in a Document Collection. It then creates an Excel spreadsheet and enters data into the spreadsheet from each document in the Document Collection (project name, project catagory, hours worked per day on that project).
Everything works fine. But what I want to do now is put a formula into a cell that sums the columns, e.g. =SUM(E:3:E:15). I can even get that to work, sort of.
My problem is that the formula gets put into the cell as: =SUM(‘E:3’:‘E:15’) (single quotation marks around the cell names).
My question is how to get an Excel formula into a cell from LotusScript? I can refer to the columns by either letter or number, but I just can’t figure out how to do it correctly.
Here’s my snippet of code:
myFormula$="=SUM(E3:E"& Cstr(StartRow+i-1) & ")" '<---I know it will always start in Column,Row E3
mySheet.rows(startrow+i).NumberFormat="0" '<--I format the row cells as a number
Print myFormula$ '<----This prints =Sum(E3:E15) (in my test, there were 13 rows of data)
mySheet.cells(StartRow+i,5).FormulaR1C1=myFormula$ '<–This puts the formula into the cell, but it comes out as: =SUM(‘E:3’:‘E:15’) and Excel reports that there is an error in the formula.
This feature is not a deal-breaker, but it would be a nice touch to add.
[this was revised to add the crucial line of code I forgot to put in when I posted originally]