+ Reply to Thread
Results 1 to 8 of 8

VBA macro will only run once. Help please!

  1. #1
    Registered User
    Join Date
    01-30-2015
    Location
    UK
    MS-Off Ver
    WINDOWS 7
    Posts
    9

    VBA macro will only run once. Help please!

    Hello there,

    I'm using the following code to rename the worksheets based on cell data:

    Please Login or Register  to view this content.
    I've linked this to a button on Sheet 1, which will run the code and rename the sheets. However, it only works once. After that, I have to save or exit for the code to run again. What am I doing wrong?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: VBA macro will only run once. Help please!

    Hi and welcome to the forum.


    Your code works for me.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Registered User
    Join Date
    01-30-2015
    Location
    UK
    MS-Off Ver
    WINDOWS 7
    Posts
    9

    Re: VBA macro will only run once. Help please!

    Hello there. It's works for me, too, but only once. If I change the cell data, then press the button to run the code again, nothing happens. I have to either save the file or close and reopen for it to work again. Any ideas? Could it be my Excel settings, rather than anything missing from the code?

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA macro will only run once. Help please!

    Can you post your workbook Tayles? What you describe sounds strange, and I can get it to run multiple times on my end without issue.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VBA macro will only run once. Help please!

    Works fine, as many times as you want.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    01-30-2015
    Location
    UK
    MS-Off Ver
    WINDOWS 7
    Posts
    9

    Re: VBA macro will only run once. Help please!

    Well now it's working for me! Didn't change anything, but out of the blue it started working. Very strange. Sorry for wasting your time.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VBA macro will only run once. Help please!

    No problem, it happens.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA macro will only run once. Help please!

    No worries, glad it worked out

+ 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. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  2. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  3. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  4. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  5. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 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