Results 1 to 2 of 2

Search routine

Threaded View

dschmitt Search routine 06-17-2010, 10:00 PM
dschmitt Re: problem with search... 06-17-2010, 10:47 PM
  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Search routine

    The below script takes a strings from one column (cell by cell) and compares it with strings in another column. If it finds a match it creates a hyperlink between the two cells.

    With this script I have one problem. I will give an example.
    Lets say the seach string is "link". The script will create a hyperlink to any cell that contains this string, even for example to "blinker".
    That is not good. Is there a way to modify this code so that hits are limited to exact matches?

    For JAuth2Rw = 2 To LastRow
        JAuthName = Sheets("Author ranking").Cells(JAuth2Rw, LastColumn)
            
        With Sheets("SC-Author ranking").Range(Sheets("SC-Author ranking").Cells(2, 1), Sheets("SC-Author ranking").Cells(LastRowJ, 1))
            Set rngFoundCell = .Find(What:=JAuthName, After:=.Cells(1, 1), LookAt:=xlPart)
            If Not rngFoundCell Is Nothing Then
                strFirstAddress = rngFoundCell.Address
                Do
                    
                    Sheets("Author ranking").Hyperlinks.Add Anchor:=Cells(JAuth2Rw, LastColumn), Address:="", _
                        SubAddress:="'SC-Author ranking'!" & rngFoundCell.Address
    
                    Set rngFoundCell = .FindNext(rngFoundCell)
                Loop While Not rngFoundCell Is Nothing And rngFoundCell.Address <> strFirstAddress
            End If
        End With
    
    Next JAuth2Rw
    Last edited by dschmitt; 06-17-2010 at 10:48 PM.

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