Results 1 to 5 of 5

Excel macro stops after Replace statement

Threaded View

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    2

    Excel macro stops after Replace statement

    Take the following simple macro:

    Range("A1:C1").Select
    Selection.Replace What:="OldText", Replacement:="NewText", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Range("A3").Select
    The macro stops after the Selection.Replace [...] statement; it makes the replacements OK, but stays on range A1:C1 and never selects range A3. I cannot get the macro do to *anything* after the Selection.Replace task. The macro does not show any error; just stops.

    I suspect this is because Excel would normally pop up an info dialog "Excel has completed its search and has made [n] replacements" (on which the user has to click OK), although I do not see this dialog when running the macro. Could this be causing the macro to freeze? Is there a way of suppressing this Replace info dialog from within the macro? I tried Application.DisplayAlerts = False - to no avail.
    Last edited by jean-marc; 08-10-2011 at 03:33 AM.

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