Consulting

Results 1 to 19 of 19

Thread: Solved: letter index

  1. #1
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location

    Solved: letter index

    Hello
    I have this function line:
    =INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2)
    I need to replace the "+2" to "+3" if the cell "A2" contains the letter"t" among
    other letters and numbers in the cell.

    Thanks

    Oleg

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    try

    =INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2+ISNUMBER(SEARCH("t",A2)))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Bob, I had envisaged something more like this:

    =If(IsNumber(Search("t",A2)),INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+3, INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+2)

    On the basis that if it finds the value "t" in A2 it changes the function to +3 else remains at the original function. I'm guessing I must be wrong then.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi thanks

    say where do i see that instead of"+2" is "+3"?

  5. #5
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Quote Originally Posted by Aussiebear
    Bob, I had envisaged something more like this:

    =If(IsNumber(Search("t",A2)),INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+3, INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+2)

    On the basis that if it finds the value "t" in A2 it changes the function to +3 else remains at the original function. I'm guessing I must be wrong then.
    Hi
    thanks for the quik replay
    i will check it in a few minuts i think you that this is what i need

  6. #6
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    hi

    this is not working it gives me some excel error but i think the idea is exactly what meant

  7. #7
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Post the error message. We can't see over your shoulder
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Aussiebear
    Bob, I had envisaged something more like this:

    =If(IsNumber(Search("t",A2)),INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+3, INDEX(Sheet1!$C:$C,Match(A2,Sheet1$B$B,0)+2)

    On the basis that if it finds the value "t" in A2 it changes the function to +3 else remains at the original function. I'm guessing I must be wrong then.
    Well, 3 is 2+1, so you don't need to test for the letters and repeat the core formula, just add 1 if t is in cell A2.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Or to put it another way, you can simplify yours to

    =INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2+IF(ISNUMBER(SEARCH("t",A2)), 1,0))

    which is the same as mine, I just use no IF statement
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by oleg_v
    hi

    this is not working it gives me some excel error but i think the idea is exactly what meant
    There are a few typos in Bear's answer

    =IF(ISNUMBER(SEARCH("t",A2)),INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+3) ,INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2))

    but mine is better.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    i fixed the error but the results are not what i need

    when the cell "A2" contains the letter "t" this writes me N/A instead of activating the index function and when the cell does not contain the letter "t" it writes me "false" instead of activating the other index function.

    Thanks

  12. #12
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Please post your workbook
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  13. #13
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    HI
    Attached the file in the sheet1 you can see the dimensions
    in the sheet2 you can see the index function

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    My formula works perfectly, although it should be 2.071 not 0.061 because 0.061 is 4 rows beyond, not 2.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  15. #15
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    My testing shows that the following formula works;

    =IF(ISNUMBER(SEARCH("t",A2)),INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+4) ,INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2))

    My thanks to Bob for the hints
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  16. #16
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Aussiebear
    My testing shows that the following formula works;

    =IF(ISNUMBER(SEARCH("t",A2)),INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+4) ,INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2))

    My thanks to Bob for the hints
    As does

    =INDEX(Sheet1!$C:$C,MATCH(A2,Sheet1!$B:$B,0)+2+(ISNUMBER(SEARCH("t",A2))*2) )

    assuming an error on the original post, corrected later by the OP
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  17. #17
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Bob, I think the issue comes about because not enough information was provided in the initial post. I am firmly of the opinion the people should where ever possible attach a workbook. This way those trying to assist get to see a fuller picture. But then I'm preaching to the converted in your case.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  18. #18
    VBAX Tutor
    Joined
    Dec 2009
    Posts
    295
    Location
    Thanks

    In the futute i will provide more information and attach the workbook

    great job every one and thanks a lot

  19. #19
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Please mark the thread as "Solved" by using the Thread tools options just above the first post
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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