Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Cell Reference

 Post Reply Post Reply
Author
Becker Greg View Drop Down
New Member
New Member
Avatar

Joined: 30 Aug 2011
Posts: 2
Post Options Post Options   Quote Becker Greg Quote  Post ReplyReply Direct Link To This Post Topic: Cell Reference
    Posted: 31 Aug 2011 at 10:36am
I'm using the FlexCel API to create a reference to a cell in another sheet (same workbook/file).  I want the value of cell B3 in Sheet1 to be "='Sheet2'!C4".  Here is how I'm doing it now (VB):

Given s2Row  = 4 and s2Col = 3...

xls.SetCellValue(1, 2, 3, New TFormula("='Sheet2'!" & TCellAddress.EncodeColumn(s2Col) & CStr(s2Row)), -1)

Is there a better way?  Thanks in advance.

--
Greg

Back to Top
Adrian Gallero View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 1237
Post Options Post Options   Quote Adrian Gallero Quote  Post ReplyReply Direct Link To This Post Posted: 31 Aug 2011 at 12:23pm
Hi,
I think that is ok. But if you prefer, you could use:

        Dim addr As TCellAddress = New TCellAddress("Sheet2", s2Row, s2Col, FalseFalse)
        xls.SetCellValue(1, 2, 3, New TFormula("=" & addr.CellRef), -1)

Regards,
  Adrian.
Back to Top
Becker Greg View Drop Down
New Member
New Member
Avatar

Joined: 30 Aug 2011
Posts: 2
Post Options Post Options   Quote Becker Greg Quote  Post ReplyReply Direct Link To This Post Posted: 31 Aug 2011 at 2:07pm
Thanks, Adrian.  Both work but your suggested way actually makes the code a bit more readable in my opinion.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down