+ Reply to Thread
Results 1 to 3 of 3

Macro to run all sheets is getting stuck in a loop

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Macro to run all sheets is getting stuck in a loop

    Hi guys,

    I've got this here peice of code

    Please Login or Register  to view this content.
    The macro is supposed to run on all sheets (305 of them), and as is obvious, auto fit all the columns, clean up some of the data in column K (phone numbers, some of which prefixes/suffixes I want removed) and then add the count formula to N2 and O2 (counting phone calls between 10-20 mins, and phone calls in excess of 20+)

    The code works when I remove the "for all sh" and run it on an individual sheet. When I try to run the code above, it gets stuck in a loop, repeatedly adding 2 new rows to the first sheet only.

    Most of this is a recorded macro, and I'm not very VBA literate, so I'm not sure what I've done wrong here?

    Thanks guys!

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to run all sheets is getting stuck in a loop

    The reason it is only working on one sheet is because you didn't declare the sheet (sh) for each range so it just picks the range from the active sheet over and over again.

    Edit: Untested but try this:

    Please Login or Register  to view this content.
    Last edited by stnkynts; 10-28-2013 at 08:09 PM.

  3. #3
    Registered User
    Join Date
    10-16-2013
    Location
    Queensland, Australia
    MS-Off Ver
    MS365, Version 2202
    Posts
    73

    Re: Macro to run all sheets is getting stuck in a loop

    Thanks so much for the help! I knew I was missing something silly!

    After you pointed out my error, I tried your code which works, and also figured out that if I add

    Please Login or Register  to view this content.
    at the start and

    Please Login or Register  to view this content.
    it also works! Thanks for helping me with new code and finding my mistake

    Cheers!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Do - Loop Until loop with randbetween gets stuck
    By supern0va in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2012, 06:06 AM
  2. Stuck on a Loop
    By adamcross in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2012, 07:50 AM
  3. Stuck in a loop
    By dem86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 01:20 PM
  4. stuck in a Do Loop?
    By keatonlg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2009, 12:35 AM
  5. HELP - Stuck in loop
    By gti_jobert in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2006, 08:41 AM

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