+ Reply to Thread
Results 1 to 10 of 10

COde for selecting second term...

  1. #1
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    COde for selecting second term...

    Hi all,

    I am writing a equation in if statement...Is there a procedure to select the the second and third letter from a sentence and write a condition based on that...

    I mean, say if I had 1XY in cell A1 and I want to write a if condition based on the XY from 1XY term, how can i do that?

    Thanks in advance,

    Sathish.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: COde for selecting second term...

    One way:
    =IF(NOT(ISERROR(SEARCH("XY",A1,1))),"Yes","No")
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: COde for selecting second term...

    Not sure if you are doing this in VBA or a formula so:
    VBA:
    Please Login or Register  to view this content.
    Formula:
    Please Login or Register  to view this content.
    for example.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: COde for selecting second term...

    Thanks for quick reply,

    SAy in cell A1 if I want to use any number say S53XY, S432XY or any number with XY in the last two places, is there a way to refine this code...

    Thanks.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: COde for selecting second term...

    If you always want the last two:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: COde for selecting second term...

    Hi,

    I am not using VBA in this project...Is it possible write a formula...

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: COde for selecting second term...

    Well, you did post in the Programming section, and your title mentions code, so...
    Try this:
    =IF(RIGHT(A1,2)="XY","Yes","No")

  8. #8
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: COde for selecting second term...

    Sorry for that...

    Thanks alot...it works...Have a great day...

  9. #9
    Forum Contributor
    Join Date
    09-04-2007
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    133

    Re: COde for selecting second term...

    one last question here...

    say if I have S543X, 1Y , S23P and S543XY and I wrote a formula as follows

    =IF(RIGHT($I$363)="P",Input!E18,IF(RIGHT($I$363)="X",-Input!E18,IF(RIGHT($I$363)="Y",Input!E18,IF(RIGHT($I$363,2)="XY",-Input!E18,IF(RIGHT($I$363)="S",Input!E18,"NG")))))

    Problem here is:

    If I select S543XY in I363 cell, I should get negative value, instead I am getting + value which I am getting from 3rd condition.

    Can u please refine the code.

    Thanks.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: COde for selecting second term...

    Just move the check for XY so it appears before the check for Y.

+ 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