Re: [ExcelDna] How can I read data in a cell which contain reference from my macro type function?

239 views
Skip to first unread message

Patrick O'Beirne

unread,
Mar 13, 2013, 10:14:39 AM3/13/13
to exce...@googlegroups.com
The value of A1 IS the same as the value in B1. That's it, you have
it. What do you really mean?

On 13/03/2013 13:55, Yeolhyun Kwon wrote:
> Let's say.... in the cell, A1, the formula is
>
> =B1
>
> And I want to get the data in the cell B1 from the cell A1.
>
> Is it possible and how can I do it?
> --
> You received this message because you are subscribed to the Google
> Groups "Excel-DNA" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to exceldna+u...@googlegroups.com.
> To post to this group, send email to exce...@googlegroups.com.
> Visit this group at http://groups.google.com/group/exceldna?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Patrick O'Beirne

unread,
Mar 14, 2013, 5:30:24 AM3/14/13
to exce...@googlegroups.com
It will give you the value of the Activecell which at that moment is A1, which for that specific formula is the same as the value in B1.
The contents of B1 may be a value or a formula, the only way you know that is to look at B1 either .value or .formula or .formular1c1
I'm not familiar with C#, I have provided a getting started guide for VB.Net aimed at VBA programmers at
http://www.sysmod.com/vba-to-vb.net-xll-add-in-with-excel-dna.pdf

On 14/03/2013 00:38, Yeolhyun Kwon wrote:
> Sorry for my poor English.
> Anyway, I made a mistake. What I meant was...
> C# code:
> public static void test()
> {
>     dynamic xlApp = ExcelDnaUtil.Application;
>     dynamic thisCell = xlApp.ActiveCell; // The cursor is at A1 and it's formula is '=B1'.
> .
> .
> .
> I thought 'thisCell.Value' doesn't give me the content of B1. But I tested again and it did.
> Something's wrong with debugging process.
> Thanks for your attention, anyway.
>    
>
>
> 2013占쏙옙 3占쏙옙 13占쏙옙 占쏙옙占쏙옙占쏙옙 占쏙옙占쏙옙 11占쏙옙 14占쏙옙 39占쏙옙 UTC+9, sysmod 占쏙옙占쏙옙 占쏙옙:

Govert van Drimmelen

unread,
Mar 14, 2013, 5:40:08 AM3/14/13
to Excel-DNA
You also need to be aware that the ActiveCell is the cell currently
selected by the user, so won't be the same every time your UDF is
calculated.

You might rather be looking for Application.Caller, which is the
current cell from which your function is being called.

-Govert
> > > For more options, visithttps://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages