+ Reply to Thread
Results 1 to 2 of 2

Find and Replace function in larger mode

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    46

    Find and Replace function in larger mode

    Can I use this code for 400 words what is needed to replace with spaces?
    If a copy all those 400 words into "What = Array("")" line then all those 400 word become red(maybe it becomes red because all those 400 words in going in 9 rows)

    What code can i use to replace 400 diffrents word with spaces?


    [Select Code] copy to clipboard

    Sub ExampleA()
    Dim Rng As Range
    Dim What As Variant
    Dim Repl As Variant
    Dim i As Long


    What = Array("XYZ000001", "XYZ000002", "XYZ000004")
    Repl = Array("ABC000123", "ABC000124", "ABC000125")

    For i = 0 To UBound(What)

    Set Rng = ActiveSheet.UsedRange
    Rng.Replace What:=What(i), Replacement:=Repl(i), MatchCase:=False
    Next i
    End Sub

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Find and Replace function in larger mode

    I would put the 400 words in their own worksheet. In my example, in a sheet called "words" in A1 thru OJ1.
    These are read into a 2D array in VBA. Another sheet called "data" is activated. This sheet contains the data to be modified. Each of the cells in ActiveSheet.UsedRange is examined and if one of the "words" is found, it is replaced by a single space:

    Please Login or Register  to view this content.
    Gary's Student

+ 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