+ Reply to Thread
Results 1 to 5 of 5

Find and Replace Macro- Within Workbook or Sheet

  1. #1
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Find and Replace Macro- Within Workbook or Sheet

    If I do a Find (or replace), under 'Options' is 'Within'...
    I can manually pick 'sheet' or 'Workbook', but that will be a sticky change.
    I have a macro that needs to do a 'sheet-only' replace.
    But, if I did a 'Workbook' search earlier, that macro does some unpleasant things.
    I have several sheets with source data, that gets copied to a target sheet. within that sheet (during the copy) I need to replace a value.
    If I picked 'Workbook' before, the source changes too (BAD).
    How can I make the macro force a sheet-only replace?
    Last edited by Rhudi; 03-14-2013 at 09:19 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find and Replace Macro- Within Workbook or Sheet

    This is a bug (or oversight) with the Replace method. It's not an issue with the Find method.

    With the Find method, if you specify a specific worksheet and range to search, it will not search the entire workbook regardless of the previous WithIn setting. Unfortunately, the Replace method doesn't respect the same usage.

    The work-around for the Replace method is to first do a dummy Find to reset the WithIn setting to search just the worksheet.

    Example: do this before your Replace.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Find and Replace Macro- Within Workbook or Sheet

    bugs like this keep us awake and alert. Well, that or caffeine dependant.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find and Replace Macro- Within Workbook or Sheet

    You're welcome.

  5. #5
    Forum Contributor Rhudi's Avatar
    Join Date
    03-08-2013
    Location
    South Carolina, US
    MS-Off Ver
    Professional Plus 2016 aka Office 365
    Posts
    199

    Re: Find and Replace Macro- Within Workbook or Sheet

    ...and thank you (sorry, I wasn't awake earlier)

+ 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