+ Reply to Thread
Results 1 to 3 of 3

VBA to find and select text within text and highlight

  1. #1
    Registered User
    Join Date
    05-09-2011
    Location
    Bridgeport, Connecticut
    MS-Off Ver
    Excel 2010
    Posts
    4

    VBA to find and select text within text and highlight

    I have adopted code from this forum to find all cells with text that matches user-entered text and which opens the color palette so users can choose the color to highlight that text. However, while the code does all this very well, it does not find text within text. The built-in Excel search function does find text within text, and that it what I am trying to get the code to do, with the additional benefit of highlighting that text (or at least the cell in which it is contained). I cannot figure out how to get the VBA search to work when the search text has at least one other character or number in the cell.

    This is the code I have:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 05-10-2011 at 06:49 PM. Reason: Added Code Tags

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: VBA to find and select text within text and highlight

    look at this code and try it. Does it works like you want it to? I'm not sure.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: VBA to find and select text within text and highlight

    try any of the following function in vba

    instr
    worksheetfucntion.search

    see vba help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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