+ Reply to Thread
Results 1 to 7 of 7

To find partial text

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    To find partial text

    Hi

    Below is my search and find program. It is fine if I find whole word but it is not working when i try to find partial text.

    Seach keyword : max

    The following texts available in the rows and the program should find below texts

    maxddd
    ddmaxfff
    ddmax


    inp = InputBox("Enter The Keyword To Search")
    uinp = UCase(inp)
    
    For i = 6 To 500
    
    Worksheets("Sheet1").Cells(i, 5).Select
    
    v1 = UCase(Worksheets("Sheet1").Cells(i, 5).Value)
    v2 = UCase(Worksheets("Sheet1").Cells(i, 6).Value)
    v3 = UCase(Worksheets("Sheet1").Cells(i, 7).Value)
    v4 = UCase(Worksheets("Sheet1").Cells(i, 8).Value)
    v5 = UCase(Worksheets("Sheet1").Cells(i, 9).Value)
    
    
    If uinp = "*" & v1 & "*" Or uinp = "*" & v2 & "*" Or uinp = "*" & v3 & "*" Or uinp = "*" & v4 & "*" Or uinp = "*" & v5 & "*" Then
    rownumb = ActiveCell.Row
    Worksheets("Sheet1").Rows(rownumb & ":" & rownumb).Hidden = False
    k = 1
    End If
    
    Next i

    It is not working

    If uinp = "*" & v1 & "*" Or uinp = "*" & v2 & "*" Or uinp = "*" & v3 & "*" Or uinp = "*" & v4 & "*" Or uinp = "*" & v5 & "*" Then
    Please help.

    Thanks.
    Last edited by gan_xl; 08-06-2013 at 11:07 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,099

    Re: To find partial text

    Edited: Sorry, the solution offered didn't work. Try:

    inp = InputBox("Enter The Keyword To Search")
    uinp = UCase(inp)
    
    For i = 6 To 500
    
    Worksheets("Sheet1").Cells(i, 5).Select
    
    v1 = UCase(Worksheets("Sheet1").Cells(i, 5).Value)
    v2 = UCase(Worksheets("Sheet1").Cells(i, 6).Value)
    v3 = UCase(Worksheets("Sheet1").Cells(i, 7).Value)
    v4 = UCase(Worksheets("Sheet1").Cells(i, 8).Value)
    v5 = UCase(Worksheets("Sheet1").Cells(i, 9).Value)
    
    
    If (InStr(1, v1, uinp)) _
    Or (InStr(1, v2, uinp)) _
    Or (InStr(1, v3, uinp)) _
    Or (InStr(1, v4, uinp)) _
    Or (InStr(1, v5, uinp)) _
    Then
        rownumb = ActiveCell.Row
        Worksheets("Sheet1").Rows(rownumb & ":" & rownumb).Hidden = False
        k = 1
    End If
    
    Next i

    Regards, TMS
    Last edited by TMS; 08-06-2013 at 10:04 AM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    Re: To find partial text

    Thank you so much, second one was working perfectly.

    Thanks.

  4. #4
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    Re: To find partial text

    Thank you so much, second one was working perfectly.

    Thanks.

  5. #5
    Forum Contributor
    Join Date
    03-13-2013
    Location
    Mumbai
    MS-Off Ver
    Excel 2003
    Posts
    152

    Re: To find partial text

    Sorry, it is not working. Any other way please?

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,099

    Re: To find partial text

    Are you looking at the original solution offered or the revised one? Maybe just check post #2 again.

    You probably need to share a sample workbook. I can't keep guessing at what your workbook structure, content and code look like.

    I used it to hide rows, rather than unhide them to see if it picked up the right information. Seemed OK.

    Regards, TMS

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,099

    Re: To find partial text

    You're welcome. Thanks for the rep.

    Sorry for the confusion ... I realised the first solution didn't work and replaced it (no point leaving it there).


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  2. [SOLVED] Conditional formating based on text in 2 columns (but only partial text!)
    By Icehockey44 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-19-2012, 06:26 AM
  3. [SOLVED] Find partial text in cell and assign variable a value if found
    By lday75 in forum Excel General
    Replies: 4
    Last Post: 07-26-2012, 01:36 PM
  4. Replies: 16
    Last Post: 04-20-2010, 01:27 PM
  5. matching partial text within one cell to partial text within another
    By Solstice in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-03-2010, 09:13 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