Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6649111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:44:07+00:00 2026-05-26T00:44:07+00:00

I am searching for text/strings in an excel sheet provided by the customer. The

  • 0

I am searching for text/strings in an excel sheet provided by the customer. The problem is that sometimes the excel Find function works and sometimes it does not. For eg if the excel sheet looks like below:

PartID Description Reference  
1234    abc         R3
4567    def         C34
4512    ghi         R2

Lets say i searched for R2 and I found it, but when i search for R3 it just won’t hit it. It will find anything after R2 that looks like R3 like R33, R31 etc. Looks like it starts checking from its last position, which was R2’s position. Below is my function:

Sub addFeedernoToFile(PARTS As Integer, ByRef counter As Integer, fileptrsq As String, ws_sq As Worksheet, tempList() As String)

    Dim i As Integer, k As Integer, found As Integer
    Dim LastAddress As String

    Dim xlSearchWithin1 As XlSearchWithin

    Set Search_Range = Columns("C")

        For i = 1 To PARTS
            searchstring = tempList(counter)

            With Search_Range
                Set c = ws_sq.Cells.Find(What:=searchstring, _
                                         After:=ws_sq.Range("C3"), _
                                         SearchOrder:=xlByColumns, _
                                         MatchCase:=False, _
                                         LookAt:=xlPart, _
                                         SearchDirection:=xlNext)

                On Error Resume Next
              ' keep track of where we are. If we are in the loop below and hit            
              ' LastAddress this means we have looped back to the begining.
                LastAddress = c.Address     

                'loop until we find the part
                Do Until c Is Nothing

                    found = 1
                    Dim splitter() As String

                    splitter = Split(c.Value, ",")

                    For k = 0 To UBound(splitter)
                        If splitter(k) = searchstring Then
                            firstaddress = c.Address
                            itemRow = Mid(firstaddress, 4, Len(firstaddress) - 3)
                            feederno = ws_sq.Range("F" & itemRow)
                            counter = counter - 1
                            found = 0
                            Exit For
                        End If
                    Next

                    Set c = ws_sq.Cells.FindNext(After:=c)

                   'we loop until we find our part the file, and if found
                    'we break out then.
                    If found = 0 Then
                        Exit Do
                    End If

                    If LastAddress = c.Address Then
                        Exit Do
                    End If
                Loop    ' end do until
            End With    ' end with search_range
        Next            ' end for
End Sub

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:44:08+00:00Added an answer on May 26, 2026 at 12:44 am

    It looks like it’s not grabbing R3 right away because you start at C3, eventually it should hit it after you search through everything else. Remember the parameter “After:=” says that after that cell it will start searching, so you might want to start the search at C2, so you would need to put

    After:=ws_sq.Range("C1")
    

    Also, if you want an exact search you could put

    LookAt:=xlWhole
    

    With xlPart you’ll pick up everything else. This piece of code will make you start from the last position:

    Set c = ws_sq.Cells.FindNext(After:=c)
    

    but the main search you did won’t do that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm searching files and returning lines that include the search text, and I'm not
I'm searching for an algorithm to compress small text strings: 50-1000 bytes (i.e. URLs).
I need to allow full-text searching on two fields that are concatenated together. In
Is there a way to find an SVN revision by searching for a text
I have 5 different strings i am searching for in a text file. I
I'm searching about a sort of hash function to index similar text. So for
I'm trying to find LF characters that appear between double quotes. The text file
I would like to do full-text searching of data in my Ruby on Rails
I'm using the acts_as_tsearch plugin for rails to do full text searching with Postgresql.
I'm searching for UUIDs in blocks of text using a regex. Currently I'm relying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.