+ Reply to Thread
Results 1 to 22 of 22

Find second entry for a search

  1. #1
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Find second entry for a search

    This code finds the first entry for what is in Sheet1 A5, but how do I find the second entry for this search, not the first?

    Please Login or Register  to view this content.
    Thanks guys!
    Last edited by excelcandy; 10-15-2013 at 03:43 PM.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    Hi Excelcand,
    maybe so
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find second entry for a search

    [CODE]
    Sub INeedToSearchForCellValue()
    Dim rngFound As Range
    Set rngFound = Sheets("Sheet2").Cells.Find(What:=Sheets("Sheet1").Range("A5").Value, _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    set rngFound = Findnext(rngFound)
    If rngFound Is Nothing Then
    MsgBox "No match found. ", , "No Match"
    Else
    Application.Goto rngFound
    End If
    End Sub

  4. #4
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Quote Originally Posted by nilem View Post
    Hi Excelcand,
    maybe so
    Please Login or Register  to view this content.
    This isn't working, error on
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Quote Originally Posted by yudlugar View Post
    [CODE]
    Sub INeedToSearchForCellValue()
    Dim rngFound As Range
    Set rngFound = Sheets("Sheet2").Cells.Find(What:=Sheets("Sheet1").Range("A5").Value, _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    set rngFound = Findnext(rngFound)
    If rngFound Is Nothing Then
    MsgBox "No match found. ", , "No Match"
    Else
    Application.Goto rngFound
    End If
    End Sub
    "Sub or function not defined"

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find second entry for a search

    Sorry yeah, forgot to reference the findnext method to a sheet. Nilem's code works fine for me though and is better than mine anyway.

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    Quote Originally Posted by excelcandy View Post
    This isn't working, error on
    Please Login or Register  to view this content.
    Please show an example of the file where the error occurs

  8. #8
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Please Login or Register  to view this content.
    This goes yellow

  9. #9
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    I meant to attach a file in which the error occurs
    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  10. #10
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    sorry, can't because of work. what could it be?

  11. #11
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find second entry for a search

    Is "66B" a named range?

  12. #12
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Ok,

    Please Login or Register  to view this content.
    works now. How do you search a certain text instead of Cell A5 ?

    thanks


    Nilem, pm me your paypal for a small reward

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find second entry for a search

    Please Login or Register  to view this content.

  14. #14
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    maybe LookIn:=xlValues instead of LookIn:=xlFormulas?
    or just
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    How do I find the third and fourth entry?

  16. #16
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    So, if this finds the first occurence and that finds the second time the value occurs,,, what code is needed to find the third and fourth ?????????????????????????????????


    First value found:
    Please Login or Register  to view this content.
    Second value found:

    Please Login or Register  to view this content.

  17. #17
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    try
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Hey, that's cool, unfortunately I don't want to count the occurences, but just select the 3rd occurence ( or 4th or 5th or ... occurence), like in the code before

  19. #19
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Find second entry for a search

    Please Login or Register  to view this content.
    change loop until cnt = 3 as appropriate for the one you want to select.

  20. #20
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Find second entry for a search

    or
    Please Login or Register  to view this content.
    @yudlugar I hope together we will (shall?) defeat this thread

  21. #21
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    Hey, I just experimented with ma skillz and found out that I just have to double the following line to find the 3rd occurence

    Please Login or Register  to view this content.
    Last edited by excelcandy; 10-10-2013 at 04:27 PM.

  22. #22
    Forum Contributor
    Join Date
    09-17-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: Find second entry for a search

    There is a problem with this, guys. If I try to get the occurence of the first, second, third and fourth search, It finds the first occurence every single time if there is only one occurence, not 2,3,4 different ones. I want to return nothing or zero in that case. (otherwise it copies the cell to the right). Pretty confusing, but logical. I want to sum up all results.
    Last edited by excelcandy; 10-10-2013 at 04:45 PM.

+ 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. Truncate text strings using LEFT and FIND/SEARCH for multiple search terms
    By ngdoherty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-17-2013, 07:51 PM
  2. [SOLVED] Search text in cells, find matching text based on list, remove all but one entry
    By adam_mc in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-30-2013, 12:50 PM
  3. Search for the last entry
    By schnett in forum Excel General
    Replies: 3
    Last Post: 07-06-2010, 09:17 AM
  4. Search row for an entry
    By ytmnd85 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2009, 09:40 AM
  5. Search Column - Find Multiple Entries - Sum Then Delete to Single Entry
    By Ledge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-19-2006, 03:30 PM

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