Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting Formulas to Excel

Status
Not open for further replies.

bpurser

Technical User
Nov 19, 2001
68
US
I am trying to create a db to help us report on equity ownership....currently, we update the total shares outstanding of a particular stock outstanding manually...and with upwards of 2200 stocks, that gets old. We have a data reporting system that links with Excel--put in the right formula, you get the data you requested...so I want to export to Excel the right formula. It looks like this:

=blp("XYZ equity", "Long_comp_name")

in excel, this returns the long company name....IF it is entered correctly....however, when exporting the forumlas, it gets entered into the cells in excel like so:

'=blp("XYZ equity", "Long_comp_name")

note the first character--which denotes a TEXT entry in Excel, preventing the formula from being read as a formula.

Short of writing code to cycle through 2200 entries in about 6 columns of excel data, and removing the offending single quote, anyone have any ideas how I can make the exported info get read as a formula?

TIA--
Ben
 
Guessing you are using the Excel via access and are coding through access ...
Select the cell where you want the formula and enter the type of value you are passing ...

EG:
Excel.Range("A1").Select
Excel.ActiveCell.Formula = ="blp("XYZ equity", "Long_comp_name")"

Tiny


Perfection is Everything
If it worked first time we wont be here!
 
Correction ...

Excel.Range("A1").Select
Excel.ActiveCell.Formula = "blp("XYZ equity", "Long_comp_name")"


Perfection is Everything
If it worked first time we wont be here!
 
damn ... I will get it right ...

Excel.ActiveCell.Formula = "=blp(""XYZ equity"", ""Long_comp_name"")"

Perfection is Everything
If it worked first time we wont be here!
 
Thanks for the replies, folks...I know bupkis about Excel Automation, and was just using the TransferSpreadsheet command to export the query where I construct the forumulas...Now for the REAL story...as mentioned, I have some 2200 recs, with about 5 of these forumulas per rec...can I get a bit more info as to the Excel coding...I can open the RS in ADO and cycle through it, but will then need to do five forumulas per line, 2200 times...

Many thanks --

Ben
 
OK, got the formulas exported, but they aren't being evaluated, unless I go into the formula bar, click it and then select OK....not sure what's up...code follows:

objExpSheet.Range("rngDataAll").Clear

objExpSheet.Activate
objExpSheet.Range("expbeg").Select

With rst1
.MoveFirst
Do While Not .EOF()
objXLApp.ActiveCell.Formula = ![Long_comp_name]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![Ticker]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![ID_CUSIP]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![EQY_Sh_Out_Real]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![EQY_Sh_Out_Dt]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![Ticker+Equity]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![Ticker+Equity+Cusip]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![Security_Typ]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![ID_ISIN]
objXLApp.ActiveCell.Offset(0, 1).Activate
objXLApp.ActiveCell.Formula = ![AMT_OUTSTANDING]
objXLApp.ActiveCell.Offset(1, -9).Activate
.MoveNext
Loop

Yes, there's gotta be a better way to move around the spreadsheet, but for now this works:

results in this:

=blp("XYZ equity"," Long_comp_name")

in the cells, but it reads just as it does above...if I click on the InsertFunction button on the toolbar, then click OK, it evaluates, but not automatically...tried F9, CTL F9, all those, but no joy.....

Any suggestions?

Ben
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top