+ Reply to Thread
Results 1 to 3 of 3

Find/Search code tweak help - Hopefully simple :)

Hybrid View

  1. #1
    Registered User
    Join Date
    04-02-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    19

    Find/Search code tweak help - Hopefully simple :)

    Hi all,

    I'm looking for a bit of help. I found this item of code on the web but need to modify it ever so slightly.

    The code below will locate and select cells containing Kenny. What I want to do is create a little search cells(C5) on my spreadsheet and have the code reference whatever is typed into the search cell. I'm sure it's a simple adjustment. I've tried changing the What:="Kenny" to What:="=C5" & What:=C5 all without success.

    Sub find()
    Cells.find(What:="Kenny", After:=ActiveCell, LookIn:=xlValues, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    True).Activate
    End Sub
    Any thoughts? The code appears to do what I need but maybe there is a better way?

    V new at this stuff so any help appreciated.

    Regards.
    Last edited by valius; 06-12-2009 at 02:10 PM. Reason: Solved by ChemistB

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Find/Search code tweak help - Hopefully simple :)

    Immediately after Sub find()
    DIM SrchName as String
    SrchName = Range("C5").Value
    and then in your Cell.Find line what = SrchName (no quotes)
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    04-02-2009
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Find/Search code tweak help - Hopefully simple :)

    Quote Originally Posted by ChemistB View Post
    Immediately after Sub find()
    DIM SrchName as String
    SrchName = Range("C5").Value
    and then in your Cell.Find line what = SrchName (no quotes)
    Does that work for you?
    Perfect! Greatly appreciated ChemistB.

    I can wrap this up before the weekend!

    Thanks you.

+ Reply to Thread

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