Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Unable to assign FormulaR1C1 correctly

The following lines create a formula (R1C1 style) and assign it to a range of
cells (please note I have edited the name used in this snippet because of the
sensitivity of the data involved):

cellForm = "='" & cjBkLast.Path & "[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"
..Range("N8:N13, N18:N24, N26:N30").FormulaR1C1 = cellForm

The cellform variable has this value in the Locals window:
"='P:\WORKBOOK_PATH\Testing\CJ\2008[CJ01_08.xls]WORKSHEET_NAME'!RC9"

However, on running this code the formula in the cells comes out as the
following
='P:\WORKBOOK_PATH\Testing\CJ\[2008[CJ01_08.xls]WORKSHEET_NAME]2008[CJ01_08.xls]PARTIAL_WORKSHEET_NAME'!$I8

Basically the formula is being mangled, and I have no idea why - the same
method of assigning formulae to cells has worked fine in other places in the
same sub. Any help or insight would be greatly appreciated.

--
There are 10 types of people in the world - those who understand binary and
those who don't.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to assign FormulaR1C1 correctly

You lost a backslash:

CellForm = "='" & cjBkLast.Path & "\[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"

Geoff wrote:

The following lines create a formula (R1C1 style) and assign it to a range of
cells (please note I have edited the name used in this snippet because of the
sensitivity of the data involved):

cellForm = "='" & cjBkLast.Path & "[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"
.Range("N8:N13, N18:N24, N26:N30").FormulaR1C1 = cellForm

The cellform variable has this value in the Locals window:
"='P:\WORKBOOK_PATH\Testing\CJ\2008[CJ01_08.xls]WORKSHEET_NAME'!RC9"

However, on running this code the formula in the cells comes out as the
following:
='P:\WORKBOOK_PATH\Testing\CJ\[2008[CJ01_08.xls]WORKSHEET_NAME]2008[CJ01_08.xls]PARTIAL_WORKSHEET_NAME'!$I8

Basically the formula is being mangled, and I have no idea why - the same
method of assigning formulae to cells has worked fine in other places in the
same sub. Any help or insight would be greatly appreciated.

--
There are 10 types of people in the world - those who understand binary and
those who don't.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default Unable to assign FormulaR1C1 correctly

And you found it for me. :D Many thanks Dave, I thought I was going mad!
PEBKAC...
--
There are 10 types of people in the world - those who understand binary and
those who don't.


"Dave Peterson" wrote:

You lost a backslash:

CellForm = "='" & cjBkLast.Path & "\[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"

Geoff wrote:

The following lines create a formula (R1C1 style) and assign it to a range of
cells (please note I have edited the name used in this snippet because of the
sensitivity of the data involved):

cellForm = "='" & cjBkLast.Path & "[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"
.Range("N8:N13, N18:N24, N26:N30").FormulaR1C1 = cellForm

The cellform variable has this value in the Locals window:
"='P:\WORKBOOK_PATH\Testing\CJ\2008[CJ01_08.xls]WORKSHEET_NAME'!RC9"

However, on running this code the formula in the cells comes out as the
following:
='P:\WORKBOOK_PATH\Testing\CJ\[2008[CJ01_08.xls]WORKSHEET_NAME]2008[CJ01_08.xls]PARTIAL_WORKSHEET_NAME'!$I8

Basically the formula is being mangled, and I have no idea why - the same
method of assigning formulae to cells has worked fine in other places in the
same sub. Any help or insight would be greatly appreciated.

--
There are 10 types of people in the world - those who understand binary and
those who don't.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Unable to assign FormulaR1C1 correctly

Sometimes, it's good to build a formula manually (with the sending workbook
open) right in a cell. Then close the sending workbook and compare it to the
string you create in the code.

That's what I did <vbg.

Geoff wrote:

And you found it for me. :D Many thanks Dave, I thought I was going mad!
PEBKAC...
--
There are 10 types of people in the world - those who understand binary and
those who don't.

"Dave Peterson" wrote:

You lost a backslash:

CellForm = "='" & cjBkLast.Path & "\[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"

Geoff wrote:

The following lines create a formula (R1C1 style) and assign it to a range of
cells (please note I have edited the name used in this snippet because of the
sensitivity of the data involved):

cellForm = "='" & cjBkLast.Path & "[" & cjBkLast.Name & "]WORKSHEET_NAME'!RC9"
.Range("N8:N13, N18:N24, N26:N30").FormulaR1C1 = cellForm

The cellform variable has this value in the Locals window:
"='P:\WORKBOOK_PATH\Testing\CJ\2008[CJ01_08.xls]WORKSHEET_NAME'!RC9"

However, on running this code the formula in the cells comes out as the
following:
='P:\WORKBOOK_PATH\Testing\CJ\[2008[CJ01_08.xls]WORKSHEET_NAME]2008[CJ01_08.xls]PARTIAL_WORKSHEET_NAME'!$I8

Basically the formula is being mangled, and I have no idea why - the same
method of assigning formulae to cells has worked fine in other places in the
same sub. Any help or insight would be greatly appreciated.

--
There are 10 types of people in the world - those who understand binary and
those who don't.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to correctly sort columns in spreadsheet Dan Excel Discussion (Misc queries) 8 December 28th 12 11:56 AM
Failing to assign expression to FormulaR1C1, what am I doing wrong? SysRq2000[_2_] Excel Programming 0 September 20th 04 12:34 PM
Failing to assign expression to FormulaR1C1, what am I doing wrong? SysRq2000 Excel Programming 1 September 20th 04 12:07 PM
Unable to Assign Data To A Cell Aanika Excel Programming 1 January 13th 04 09:45 PM
Unable to Assign Value To Cell Aanika Excel Programming 1 January 12th 04 03:18 PM


All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"