+ Reply to Thread
Results 1 to 8 of 8

R1C1 Syntax issue

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Lightbulb R1C1 Syntax issue

    Hi Guys, here is the problem:

    Cells G3, H3, and I3 are populated with any of the following data (for the respective columns):

    Aaa AAA AAA
    Aa1 AA+ AA+
    Aa2 AA AA
    Aa3 AA- AA-
    A1 A+ A+
    A2 A A
    A3 A- A-
    Baa1 BBB+ BBB+
    Baa2 BBB BBB
    Baa3 BBB- BBB-
    Ba1 BB+ BB+
    Ba2 BB BB
    Ba3 BB- BB-
    B1 B+ B+
    B2 B B
    B3 B- B-
    Caa1 CCC+ CCC
    Caa2 CCC CCC
    Caa3 CCC- NR
    Ca CC
    C C
    NR NR

    Now in Cell AA3 of my workbook, I wish to input the following formula using a macro:

    =IF(OR(G3="Aaa",G3="Aa1",G3="Aa2",G3="Aa3",G3="A1",G3="A2",G3="A3",G3="Baa1",G3="Baa2",G3="Baa3",H3="AAA",H3="AA+",H3="AA",H3="AA-",H3="A+",H3="A",H3="A-",H3="BBB+",H3="BBB",H3="BBB-",I3="AAA",I3="AA+",I3="AA",I3="AA-",I3="A+",I3="A",I3="A-",I3="BBB+",I3="BBB",I3="BBB-"),"IG",IF(OR(G3="Ba1",G3="Ba2",G3="Ba3",G3="B1",G3="B2",G3="B3",G3="Caa1",G3="Caa2",G3="Caa3",G3="Ca",G3="C",H3="BB+",H3="BB",H3="BB-",H3="B+",H3="B",H3="B-",H3="CCC+",H3="CCC",H3="CCC-",H3="CC",H3="C",I3="BB+",I3="BB",I3="BB-",I3="B+",I3="B",I3="B-",I3="CCC+",I3="CCC"),"HY",IF(AND(G3="NR",H3="NR",I3="NR"),"NR")))

    However there seems to be some syntax error in the R1C1 code that I am using inside the macro...could you guys help? thanks!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: R1C1 Syntax issue

    What code?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: R1C1 Syntax issue

    Your formula can be very much simplified if you share the method with a sample file by showing the expected output


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: R1C1 Syntax issue

    Here is the workbook guys! Thanks

    I want a macro that will input this formula automatically into cell AA3. I know the formula is innefficient but I havent found another way of doing it. Thanks
    Attached Files Attached Files

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,438

    Re: R1C1 Syntax issue

    The formula is too long to fit on a line in the VB Editor. You need to split it.

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    04-11-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    92

    Re: R1C1 Syntax issue

    Thanks a lot mate! It works now, just two questions regarding your solution:

    1. what are the differences in using the two different approaches above?
    2. What is the point of having the " & Chr(10) & " ""Condition Not Met"")))" ?

    Thanks again

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,438

    Re: R1C1 Syntax issue

    1. what are the differences in using the two different approaches above?
    Well, none, if you put the formula in cell AA3. But, if you put it somewhere else, the first one will adjust relative to the cell it goes in and the second one won't. Which may, or may not, be a good thing.

    2. What is the point of having the " & Chr(10) & " ""Condition Not Met"")))" ?
    In the absence of a sample workbook, I just put the formula as copied from your post in cell AA3 in a blank workbook. It returned FALSE because there is no data ... but, more importantly, because there is no False result in the last IF statement. Might never happen in real life but you shouldn't really leave it open ended like that.


    Regards, TMS

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,438

    Re: R1C1 Syntax issue

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Updating formulas using R1C1 syntax
    By lfeder in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2013, 04:06 PM
  2. [SOLVED] Syntax Issue
    By Vladamir in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2012, 10:36 AM
  3. Syntax to add a variable for Row Number in R1C1 format
    By Jon.R in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2011, 10:29 AM
  4. Help with Syntax Using R1C1 in VBA
    By nofzinger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2010, 11:38 AM
  5. syntax issue
    By JT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2006, 04:10 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