+ Reply to Thread
Results 1 to 5 of 5

Search Cells and Replace Text in that cell

Hybrid View

lennonjunior Search Cells and Replace Text... 05-05-2009, 09:05 PM
JBeaucaire Re: Create VBA Script 05-05-2009, 09:36 PM
lennonjunior Re: Create VBA Script 05-05-2009, 10:29 PM
JBeaucaire Re: Create VBA Script 05-05-2009, 11:42 PM
shg Re: Create VBA Script 05-05-2009, 11:45 PM
  1. #1
    Registered User
    Join Date
    05-05-2009
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Search Cells and Replace Text in that cell

    I am very new to Macros and writing VBA scripts. Here is what I am wanting to do. Search multiple cells for certain string and then replace the text of the entire cell with new text.

    For example the text may contain:
    "A Chestnut Leather Satchel Binocular Case "They'll Fight Over When You're Dead" (Binocularcase-SL-CH)"

    I want to search for SL-CH and once that is found I want to replace the contents of the entire cell with the following:
    Satchel Chestnut (SL-CH)

    TIA
    Last edited by lennonjunior; 05-06-2009 at 03:58 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create VBA Script

    Something simple like this maybe:
    Sub SearchReplace()
    
    ActiveSheet.UsedRange.Cells.Select
    
        For Each cell In Selection
            If cell.Text Like "*SL-CH*" Then cell.Value = "Satchel Chestnut (SL-CH)"
        Next cell
        
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-05-2009
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    2

    Thumbs up Re: Create VBA Script

    Thanks! Works Great

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Create VBA Script

    If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED].

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Create VBA Script

    Welcome to the forum. lennonjunior.

    Please be sure to read the forum rules about thread titles before starting your next thread.
    Entia non sunt multiplicanda sine necessitate

+ 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