+ Reply to Thread
Results 1 to 3 of 3

Syntax for FormulaR1C1 Using Variables

  1. #1
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Exclamation Syntax for FormulaR1C1 Using Variables

    I am new to using the FormulaR1C1 style of syntax, and am running into some (hopefully simple) problems. I am using variables, but when I input them into the formula, I believe it is searching relative cells rather than the column assigned to the variable.

    The function I am trying to produce in every active row for column "iVariable1" is as follows:



    With Range(Cells(2, iVariable1), Cells(LR, iVariable1))

    IF(AND(Cells(2, iVariable5) <>"", Cells(2, iVariable5) > Cells(2, iVariable6)), "TRUE", "FALSE")

    End With

    Here is the coding I have:

    Please Login or Register  to view this content.
    *Note: Each of the iVariable's represents a column.

    Is there a way to have the formula grab the column I am looking for, rather than it finding an irrelevant column?

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Syntax for FormulaR1C1 Using Variables

    I believe it is searching relative cells rather than the column assigned to the variable.
    In R1C1 notation, the brackets [] denote relative references. A number without brackets denotes an absolute reference. So

    RC[-1] denotes the cell in the same row and one column to the left of the cell containing the formula
    R1C[-1] denotes the cell in row 1 (absolute) and one column to the left of the cell containing the formula
    R1C1 denotes the cell at the intersection of row 1 and column 1 no matter where the formula is located (absolute reference)

    It sounds like you want an absolute reference, so you need to drop the brackets and write the reference in absolute syntax.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    09-06-2012
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    225

    Re: Syntax for FormulaR1C1 Using Variables

    That certainly was my problem lol, I knew it was something easy like that. Much thanks for your time and expertise.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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