+ Reply to Thread
Results 1 to 5 of 5

Syntax to add a variable for Row Number in R1C1 format

  1. #1
    Registered User
    Join Date
    06-09-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    17

    Syntax to add a variable for Row Number in R1C1 format

    Hello, I have taken over a project half way done, and I was hoping someone coule help me out with the proper syntax for using a variable as the row number. In the code I am checking if there is an error, using vlookup to find values to search. I would like to use LastRow as the row number, rather than define a set range in the Vlookup:


    c.offset(0,13).FormulaR1C1 = "=IF(ISERROR(VLOOKUP(RC[-10]," & WSName & "!R2C6:R[LastRow]C13,5,FALSE)),"""",VLOOKUP(RC[-10]," & WSName & "!R2C6:R[LastRow]C13,5,FALSE))"
    I am having an issue with the quotes and the use of &'s, as the range I am searching is on another worksheet (WSName)... Any help much appreciated!
    Thanks!
    Last edited by Jon.R; 06-09-2011 at 10:11 AM.

  2. #2
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Dorset, UK
    MS-Off Ver
    Office 2003, Office 2007
    Posts
    131

    Re: Syntax to add a variable for Row Number in R1C1 format

    Assuming LastRow is a code variable (and not a named range), your LastRow bits also need to be concatenated in. Try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Syntax to add a variable for Row Number in R1C1 format

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,334

    Re: Syntax to add a variable for Row Number in R1C1 format

    Hi Jon.R and welcome to the forum.

    Try
    Please Login or Register  to view this content.
    Replace the LastRow in your formula with " & LastRow & "

    I hope that works.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    06-09-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Syntax to add a variable for Row Number in R1C1 format

    Thanks guys! each of your solutions worked! I like the way mikerickson suggested a new RangetoSearch function. Perfect!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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