+ Reply to Thread
Results 1 to 10 of 10

Simple VBA: Search string and color it

  1. #1
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Simple VBA: Search string and color it

    I am looking for a simple VBA code, to search excel sheet2 for a string "0000X000xx1" and color all of them in red if found in cells.
    Then extend the string color forward and backward until a line break is found.
    Attached Files Attached Files
    Last edited by trueb; 09-16-2022 at 04:20 AM.

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Simple VBA: Search string and color it

    Hi trueb,

    Is there always a space between the string you want to search & other strings or it could be all connected? Normally such questions tend to be more complex once all variations/cases are identified. I suggest that you post a sample file with clear examples of before (current setup) & after (expected results) for the members to be able to provide you the required code instead of members wasting their time & efforts on unnecessary codes ...

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,484

    Re: Simple VBA: Search string and color it

    Please Login or Register  to view this content.
    This red snippet below...Was deceiving as it looked like a line break, but was not...
    Untitled.png
    Last edited by Sintek; 09-16-2022 at 04:26 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Simple VBA: Search string and color it

    Try below code ...
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  5. #5
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Re: Simple VBA: Search string and color it

    Thank you. without coloring, if I want to delete everything that is forward and backward of 0000X000xx1 until a line break is found then how the code can be modified?
    Last edited by trueb; 09-16-2022 at 04:55 AM.

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Simple VBA: Search string and color it

    Thanks for the Rep+ ... Try below code
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Re: Simple VBA: Search string and color it

    Quote Originally Posted by nankw83 View Post
    Thanks for the Rep+ ... Try below code
    Please Login or Register  to view this content.
    Thank you again. The VBA keeps the string "0000X000xx1" but I want to delete that as well.

  8. #8
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Simple VBA: Search string and color it

    Ok, try below updated code
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Re: Simple VBA: Search string and color it

    If I want to copy and paste everything in the next column rows respectively that is forward and backward of 0000X000xx1 until a line break is found then how the code can be modified?
    Last edited by trueb; 09-26-2022 at 04:14 PM.

  10. #10
    Registered User
    Join Date
    09-02-2022
    Location
    India
    MS-Off Ver
    2010
    Posts
    13

    Re: Simple VBA: Search string and color it

    If I want to run the same VBA in a text or CSV file how to modify the VBA?
    Last edited by trueb; 09-17-2022 at 12:37 PM.

+ 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. Simple search box column and retrive results to search box sheet
    By Tanakaka in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-08-2017, 08:47 AM
  2. search string and color cells
    By bkdimri in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2013, 04:11 AM
  3. Simple macro to search for string
    By Timmo246 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2013, 11:37 PM
  4. [SOLVED] Search for string across header row, then search for another string down found column
    By TucsonJack in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2012, 02:09 PM
  5. Replies: 0
    Last Post: 02-21-2006, 12:10 PM
  6. search a string withing a string : find / search hangs
    By itarnak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2005, 11:05 AM
  7. how do I search a pattern color & string in excel
    By jayjay17 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2005, 04:05 PM

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