+ Reply to Thread
Results 1 to 2 of 2

Thread: Find & Replace Text in Multiple WS

  1. #1
    Registered User
    Join Date
    01-31-2011
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003
    Posts
    24

    Find & Replace Text in Multiple WS

    Hello all,

    Need help in a VB macro - I have 17 worksheets in one excel file which has a lot of text. Each column has words such as Apple Icecream or Banana Sundae...etc.

    In one of the worksheets i have listed acronyms such as Apple Icecream (cell A1) APPL IC (Cell b1), Banana Sundae (cell A2) BAN SD (cell b2)......

    I have 100 such acronyms and want to change words across all sheets. Current i have the below noted code but there are 2 issues i face. 1) it doesnt do the typical find and replace. If the cell has Apple Icecream Large it would not replace it. 2) Its made to find and replace just one worksheet and not all in this workbook. Please help!!


    Dim lookup As String
    Dim replace As String


    Sub find_replace()

    Application.ScreenUpdating = False

    r = LastRow()
    Dim lr As Integer

    For lr = r To 1 Step -1

    Workbooks("Mapping_Macro.xls").Worksheets("Mapping").Activate

    lookup = Cells(lr, 1).Value
    replace = Cells(lr, 2).Value

    Workbooks("Mapping_Macro.xls").Worksheets("abc").Select


    Cells.replace _
    What:=lookup, Replacement:=replace, _
    LookAt:=xlWhole, MatchCase:=False


    Next lr

    End Sub

    Function LastRow() As Long

    Dim ix As Long
    ix = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
    LastRow = ix
    End Function
    [/FONT]

  2. #2
    Extremely Helpful member
    Join Date
    12-23-2006
    Location
    Belgium
    MS-Off Ver
    XL2003
    Posts
    6,127

    Re: Find & Replace Text in Multiple WS

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Quoting entire posts clutters the forum and makes threads hard to read !

    If you are pleased with a member's answer then use the Star icon to rate it

    Click here to see forum rules

+ 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.2.0