+ Reply to Thread
Results 1 to 4 of 4

VBA won't stop running

  1. #1
    Registered User
    Join Date
    10-21-2010
    Location
    Chicago
    MS-Off Ver
    Excel 2003, 2010
    Posts
    2

    VBA won't stop running

    The VBA will run and spit out what I need, but then it keeps running and creates a second copy (that I don’t need) and hits an error on renaming the second sheet. I only need the first output sheet that is renamed. I’m not sure why it’s not stopping after it produces the 1st output sheet. If I take out the part on renaming the sheet I just continue to get more and more copies of the same sheet until I kill the macro manually. Any ideas?

    Thanks in advance for the help

    Please Login or Register  to view this content.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: VBA won't stop running

    Hello,

    you code contains a For/Next loop that runs on each sheet in the array. In each iteration, it copies the sheet FOOD CHANNEL-FORM and then renames it with the content of cell I3, which is probably always the same content, hence producing the same sheet name. And that is not allowed.

    The code could be tidied up. Apart from not using the For/Next loop, there's a lot of selecting and activating that is not required.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA won't stop running

    You need to explain what you want the code to achieve. Currently I can't see why you need to loop through the array of sheets simply to copy one sheet. This will copy the sheet, rename it & format it.

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    10-21-2010
    Location
    Chicago
    MS-Off Ver
    Excel 2003, 2010
    Posts
    2

    Re: VBA won't stop running

    The reason I go through all those sheets, which are all pivot tables as you can see in the code, is to select 1 particular Market/Region (74 total different Market/Regions) that will all be displayed in the FOOD CHANNEL-FORM tab. And then have that FOOD CHANNEL - FORM tab copied and renamed to the appropriate Market/Region that is displayed in cell I3, which is always changing when the pivot tables Market/Region changes.

    My eventual goal is to have it run through all 74 Market/Regions and spit out a copy for each Region/Market on a separate tab. The result would be 74 tabs (one for each Region/Market
    Last edited by codsmith; 05-03-2011 at 09:42 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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