+ Reply to Thread
Results 1 to 3 of 3

Find and Replace within workbook - from Visual basic

  1. #1
    MarkS
    Guest

    Find and Replace within workbook - from Visual basic

    I need to find a string on a worksheet and change the formatting so it stands
    out. That's easy. Actually, I want to find a bunch of strings on all
    worksheets in a workbook. I recorded a macro that does the find and replace.
    I selected the "options" button on the find and replace dialog box and
    changed the "within" to "Workbook". Did the replace and it worked great.

    However, the macro does NOT contain the code to change the option from
    Worksheet to workbook! :-(

    I imagine it's a one liner. Any idea what that is?

  2. #2
    mpeplow
    Guest
    While you were recoding the macro after you click on replace (or find) did you click on option the select 'within workbook' ?

  3. #3
    Bernie Deitrick
    Guest

    Re: Find and Replace within workbook - from Visual basic

    For example.....

    Dim mySht As Worksheet

    For Each mySht In Worksheets
    mySht.Cells.Replace What:="Test", Replacement:="Fill", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Next mySht

    HTH,
    Bernie
    MS Excel MVP


    "MarkS" <[email protected]> wrote in message
    news:[email protected]...
    >I need to find a string on a worksheet and change the formatting so it stands
    > out. That's easy. Actually, I want to find a bunch of strings on all
    > worksheets in a workbook. I recorded a macro that does the find and replace.
    > I selected the "options" button on the find and replace dialog box and
    > changed the "within" to "Workbook". Did the replace and it worked great.
    >
    > However, the macro does NOT contain the code to change the option from
    > Worksheet to workbook! :-(
    >
    > I imagine it's a one liner. Any idea what that is?




+ 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