+ Reply to Thread
Results 1 to 3 of 3

Ending Looping Macro

  1. #1
    Registered User
    Join Date
    12-11-2003
    Posts
    14

    Ending Looping Macro

    I've got this code that is giving me an error (Run time Error '91').

    The code is looking for formulas that begin with "=XXX" and copy/paste values any cell that contains this formula.

    Here is the code:
    Sub XXX()
    Cells.Find(What:="=XXX", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub

    Sub XXX_Loop()
    Do
    XXX
    Loop
    End Sub

    You can probably tell that when Excel doesn't find any additional "=XXX" formulas, the error message pops up. I've tried a few things and nothing seems to work.

    Although the macro is doing what it needs to do, I'd like to have a "cleaner" running macro that doesn't end with an error message. Any help will be greatly appreciated.

    EDIT: The simple solution would be to copy/paste values the whole worksheet but I would like to leave some "live" formulas (e.g. "=A24/A25") that do not start with the "=XXX" custom function.

    Thanks,
    cparaske
    Last edited by cparaske; 06-13-2005 at 03:59 PM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Hi
    Please Login or Register  to view this content.
    I've got this code that is giving me an error (Run time Error '91').

    The code is looking for formulas that begin with "=XXX" and copy/paste values any cell that contains this formula.

    Here is the code:
    Sub XXX()
    Cells.Find(What:="=XXX", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub

    Sub XXX_Loop()
    Do
    XXX
    Loop
    End Sub

    You can probably tell that when Excel doesn't find any additional "=XXX" formulas, the error message pops up. I've tried a few things and nothing seems to work.

    Although the macro is doing what it needs to do, I'd like to have a "cleaner" running macro that doesn't end with an error message. Any help will be greatly appreciated.

    Thanks,
    cparaske

  3. #3
    Registered User
    Join Date
    12-11-2003
    Posts
    14
    Thanks, jindon.

    It worked like a charm.

    Kind regards,
    Cristo

+ 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