Results 1 to 6 of 6

Find and replace multiple values in one cell from list

Threaded View

shawnvon Find and replace multiple... 02-21-2015, 08:27 PM
fredlo2010 Re: Find and replace multiple... 02-21-2015, 09:30 PM
jindon Re: Find and replace multiple... 02-21-2015, 09:30 PM
shawnvon Re: Find and replace multiple... 02-21-2015, 09:34 PM
jindon Re: Find and replace multiple... 02-21-2015, 09:42 PM
shawnvon Re: Find and replace multiple... 02-21-2015, 10:03 PM
  1. #1
    Registered User
    Join Date
    02-08-2014
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    60

    Find and replace multiple values in one cell from list

    Hi, I have the below code in the attached file. What I am trying to do is find and replace multiple values contained in one cell. Looking at the file, I want the company names in column A replaced with the values in column D which represent a list of the company names in column C. See cell B25 for example. I have this code written but it only replaces the first value found and deletes the rest. I would appreciate any help. Thanks in advance.

    Sub String_Replacer()
        
        Dim ws As Worksheet, wb As Workbook
        Dim fList As Variant, I As Integer
        Dim rng1 As Range
        Dim rng2 As Range
        Dim cel As Range
        Dim strMyChar As String, strMyReplace As String
         
    Application.ScreenUpdating = False
         
        With ActiveWorkbook.Worksheets("Sheet1")
            Set rng1 = .[C1:C2405]
        End With
        With ActiveWorkbook.Worksheets("Sheet1")
            Set rng2 = .[A1:A5115]
        End With
        
        For Each cel In rng1.Cells
            strMyChar = cel.Value
            strMyReplace = cel.Offset(0, 1).Value
            
            With rng2
                .Replace What:=strMyChar, Replacement:=strMyReplace, _
                SearchOrder:=xlByColumns, MatchCase:=True
            End With
               
        Next cel
        
    Application.ScreenUpdating = True
         
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA Find & Replace Multiple Values
    By hobbiton73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2013, 03:54 AM
  2. [SOLVED] Faster way to find and replace multiple values with corresponding values
    By babbeleme1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-18-2013, 06:50 PM
  3. Find a keyword and replace with list of values from a column
    By georgemathew46 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2013, 10:34 AM
  4. Multiple Find and Replace to replace a list of strings
    By WalterP34 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2011, 07:41 PM
  5. Find and Replace values from multiple lookup values
    By Gregula82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2007, 03:12 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