writeback using VBA

Post Reply
mafteutza
Posts: 2
Joined: Mon Aug 12, 2013 8:49 am
OLAP Product: TM1
Version: TM1 Perspective
Excel Version: office professional

writeback using VBA

Post by mafteutza »

Hello,

I want to alter a cell in a slice in excel, using TM1 Perspectives. I use the formula =DBR(... to retreive the data
It works fine when i do it manually, but when i use a macro in excel, it deletes the formula and just lets the text. The formula which helps me get the data from TM1 disappears and I am left with a simple cell filled with the text i wanted to insert.

I recorded a macro when I do this manually:
Sub Macro1()
Range("D4").Select
ActiveCell.FormulaR1C1 = "1.3"
Range("D5").Select
End Sub

When I run this macro(exactly the one I recorded) it does not write back into the database. The formula which helps me get the data from TM1 disappears and I am left with a simple cell filled with the text i wanted to insert. Any clues as whis is this happening or how could i solve this?
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: writeback using VBA

Post by tomok »

mafteutza wrote:Hello,

I want to alter a cell in a slice in excel, using TM1 Perspectives. I use the formula =DBR(... to retreive the data
It works fine when i do it manually, but when i use a macro in excel, it deletes the formula and just lets the text. The formula which helps me get the data from TM1 disappears and I am left with a simple cell filled with the text i wanted to insert.

I recorded a macro when I do this manually:
Sub Macro1()
Range("D4").Select
ActiveCell.FormulaR1C1 = "1.3"
Range("D5").Select
End Sub

When I run this macro(exactly the one I recorded) it does not write back into the database. The formula which helps me get the data from TM1 disappears and I am left with a simple cell filled with the text i wanted to insert. Any clues as whis is this happening or how could i solve this?
You can't do this with a DBR formula using VBA. If you want to write back with VBA you'll have to place a value in the cell and use a call to a DBS formula to send that value to TM1.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
mafteutza
Posts: 2
Joined: Mon Aug 12, 2013 8:49 am
OLAP Product: TM1
Version: TM1 Perspective
Excel Version: office professional

Re: writeback using VBA

Post by mafteutza »

Thank you for your help.
I have another question, about DBS formula: If I use this formula, will the database be overwritten every time I recalculate the sheet? Never mind, I see that it does. Have a nice day :)
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: writeback using VBA

Post by tomok »

mafteutza wrote:Thank you for your help.
I have another question, about DBS formula: If I use this formula, will the database be overwritten every time I recalculate the sheet? Never mind, I see that it does. Have a nice day :)
It won't if your VBA creates the DBR formula, recalculates, and then destroys it.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: writeback using VBA

Post by David Usherwood »

Years ago I wrote a routine to do this fully in VBA, using Application.Run("DBSW",.....). So you don't need to put a value in a cell first. But, importantly, you don't get the Stargate view speedup if you go that route - so it's not a good idea if you have lots of numbers to send.
Post Reply