+ Reply to Thread
Results 1 to 10 of 10

Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    I'm using Range.FormulaR1C1 and Range.FormulaArray in an A1-style worksheet to create formulas in certain ranges.

    FormulaR1C1 works fine: If the formula for cell F12 includes "RC2", then the actual formula (as displayed in the worksheet) will show "$B12" in its place.

    The problem is FormulaArray. The documentation says one MUST use R1C1 notation when assigning a formula using FormulaArray. Yet when my formula contains "RC2" (and gets plugged into the A1-style worksheet) the cell reference does not get "translated" to A1 format. It still shows "RC2" (instead of, for example, $B12), which therefore refers to the WRONG CELL.

    So how do I fix this? Do I have to do something like:
    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Range.FormulaArray = "..blah blah... RC2...blah blah..."
    The issue may be with the syntax of your formula. Please show the whole formula.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Actual code is:
    Please Login or Register  to view this content.
    Owner1Col = 2
    The actual formula that gets entered in the worksheet is:
    Please Login or Register  to view this content.
    But RC2 should have been converted to $Bx (where x is current row number). Why is it not converting to A1-style (as it does correctly with FormulaR1C1)?
    By the way, the intent of this formula is to find the first occurrence of any one of a number of keywords (that are in the named range "Tables_TrustKeywordsWithLeadingSpace") within the text in cell $Bx (and return 999 if none of the keywords are found).

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Try applying the array formula in one cell then copying the formula down the column

  5. #5
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Already tried that. Still doesn't work. Even just pasting the formula into a single cell, the "RC2" reference remains unchanged.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    I can't see your data. So I have to ask what might be an obvious question; does your formula actually return a value? As a test, if you manually put the formula below in a cell, does it return an error value?

    {=MIN(IFERROR(SEARCH(Tables_TrustKeywordsWithLeadingSpace,$B2),999))}

  7. #7
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    The formula works correctly (and indeed returns the correct value) if I enter it manually (or simply change RC2 to $B2 so it references the correct cell). I just don't know why it doesn't get converted from RC2 to $B2 when it's entered using FormulaArray.

    Originally, I set this all up by manually entering the formula and confirming that everything worked OK. I then coded the macro to duplicate what I had done manually. But for some reason the "required" R1C1 format doesn't get converted to A1-style.

  8. #8
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Well, it appears that the Excel documentation (or the actual implementation) is wrong. Just tried this (on a test sheet, where the data is in cell H26):
    Please Login or Register  to view this content.
    If I stop the macro before changing back to A1 style, the actual formula in cell O26 is:
    Please Login or Register  to view this content.
    So it looks like FormulaArray is treating RC8 as an A1-style reference, in spite of what the documentation says!

  9. #9
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    I was able to use both A1 and R1C1 refernce styles when applying the formula.

    I didn't change the Application reference style before or after applying the formula using either A1 or R1C1.

  10. #10
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Range.FormulaArray - R1C1 formula in A1-style worksheet doesn't work??

    Ran a few more tests and found (if Excel is left in A1 mode):
    • FormulaArray using "RC8" results in actual formula containing "RC8" (incorrect)
    • FormulaArray using "H26" results in actual formula containing "H26" (correct! But contradicts the documentation!)
    • FormulaArray using "R[]C8" results in actual formula containing "H26" (CORRECT!)
    So apparently, FormulaArray interprets formulas with no brackets as being A1-style, while formulas that include any brackets are interpreted as R1C1 style.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Convert R1C1 Style to A1 style
    By m1ngle in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-17-2016, 08:38 PM
  2. R1C1 notation in a FormulaArray
    By n043480 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2016, 05:29 AM
  3. [SOLVED] Formula R1C1 style not working
    By amphinomos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2016, 07:01 AM
  4. [SOLVED] Range("A1")(2,2) reference style doesn't work!!
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-18-2013, 11:39 AM
  5. [SOLVED] Need to Convert Formula R1C1 into A1-style but the Formula String exceeds 255 characters
    By VBA_Gary in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2012, 12:09 PM
  6. Using R1C1 to represent a entire column in VBA formulaArray
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-18-2012, 02:22 PM
  7. Replies: 3
    Last Post: 08-23-2011, 12:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1