Results 1 to 20 of 20

Automating Find & Replace

Threaded View

PharmerGuy Automating Find & Replace 05-01-2014, 05:34 PM
greggpetersen75 Re: Automating Find &... 05-01-2014, 05:54 PM
PharmerGuy Re: Automating Find &... 05-01-2014, 05:59 PM
greggpetersen75 Re: Automating Find &... 05-01-2014, 08:03 PM
PharmerGuy Re: Automating Find &... 05-05-2014, 01:14 PM
PCI Re: Automating Find &... 05-05-2014, 01:43 PM
PharmerGuy Re: Automating Find &... 05-05-2014, 01:51 PM
PCI Re: Automating Find &... 05-05-2014, 01:59 PM
PCI Re: Automating Find &... 05-05-2014, 03:16 PM
greggpetersen75 Re: Automating Find &... 05-05-2014, 07:59 PM
PharmerGuy Re: Automating Find &... 05-07-2014, 10:26 AM
greggpetersen75 Re: Automating Find &... 05-07-2014, 10:36 AM
PharmerGuy Re: Automating Find &... 05-07-2014, 11:34 AM
PCI Re: Automating Find &... 05-07-2014, 01:08 PM
greggpetersen75 Re: Automating Find &... 05-07-2014, 03:46 PM
PharmerGuy Re: Automating Find &... 05-12-2014, 03:53 PM
greggpetersen75 Re: Automating Find &... 05-12-2014, 04:01 PM
PharmerGuy Re: Automating Find &... 05-12-2014, 04:09 PM
greggpetersen75 Re: Automating Find &... 05-12-2014, 07:33 PM
greggpetersen75 Re: Automating Find &... 05-08-2014, 12:53 PM
  1. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,086

    Re: Automating Find & Replace

    Try next code and check, check, check.
    Has been remove the space after the comma when 2 sheets where mentioned (Sheet1,Sheet2) to avoid confusion with the space inside the sheet's name
    Option Explicit
    
    Sub ReplaceData()
    Dim ObjDic   As Object
    Dim WkRg  As Range
    Dim F   As Range
    Dim G
    Dim WkSh As Worksheet
    Dim WkStg1 As String, WkStg2 As String
    Dim WkSet
    Dim I  As Integer
    Dim AAA, BBB, CCC
        Application.ScreenUpdating = False
        Set ObjDic = CreateObject("Scripting.Dictionary")
        With Sheets("Code Sheet")
            For Each F In Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
                If (F.Value <> "") Then ObjDic(F.Value) = F.Offset(0, 1).Value
            Next F
            For Each F In Range(.Range("E2"), .Range("E" & Rows.Count).End(xlUp))
                If (F.Value <> "") Then
                    If (F.Value = "All") Then
                        For Each WkSh In Worksheets
                            If (WkSh.Name <> "Code Sheet") Then
                                For Each G In ObjDic.keys
                                    WkStg1 = G
                                    Call FindReplace(WkStg1, ObjDic(G), WkSh.Name)
                                Next G
                            End If
                        Next WkSh
                    Else
                        WkSet = Split(F.Value, ",")
                        For I = 0 To UBound(WkSet, 1)
                            For Each G In ObjDic.keys
                                WkStg1 = G: WkStg2 = WkSet(I)
                                Call FindReplace(WkStg1, ObjDic(G), WkStg2)
                            Next G
                        Next I
                    End If
                End If
            Next F
        End With
        Application.ScreenUpdating = True
    End Sub
    
    Sub FindReplace(StgOrg As String, StgDest As String, WkSh As String)
        With Sheets(WkSh).Cells
            .Replace What:=StgOrg, Replacement:=StgDest, LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _
            ReplaceFormat:=False
        End With
    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. find in excel replace in word: find/replace text in text boxes and headers
    By dean.rogers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2012, 12:40 PM
  2. Automating FIND AND REPLACE
    By jrodlc8 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-21-2011, 09:30 PM
  3. Automating Find and Replace
    By jcy1011 in forum Excel General
    Replies: 3
    Last Post: 07-30-2010, 05:52 PM
  4. Automating Find and Replace function.
    By gsmonk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2007, 02:13 PM
  5. find and replace - replace data in rows to separated by commas
    By msdker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2006, 08:10 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