+ Reply to Thread
Results 1 to 4 of 4

Macro only executes in Personal Macro Book

  1. #1
    Registered User
    Join Date
    07-03-2017
    Location
    Guymon, Oklahoma, USA
    MS-Off Ver
    Office 365, 2016
    Posts
    6

    Macro only executes in Personal Macro Book

    Hello,

    I have a macro I found on another forum that I really like to use. The macro will search every cell in the active sheet to see if they are merged. If they are, it stores the range of the merged cells in a temp. range variable, unmerges the cells, then fills the range with the value of the first cell in the unmerged range (what the value was).

    The macro is saved in my personal macro workbook. I've tried lots of different ways and I cant seem to make the macro excuted on any spreadsheet I am unless i copy and paste the data into the personal macro workbook then excuted the macro. Can anyone help me figure out why it would only run in my personal macro book but not any other workbook even though the code says "active workbook?"

    Thanks in advaced for your help. I have placed the code below.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro only executes in Personal Macro Book

    Try this

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    03-28-2018
    Location
    Houston, TX
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    127

    Re: Macro only executes in Personal Macro Book

    To help you understand a little bit better what mehmetcik did here...

    When you are running code, ThisWorkbook will always refer to the workbook where the code is located. So instead of looking in the current ActiveSheet in Excel, it is looking at the ActiveSheet in the workbook where the code is located. By removing ThisWorksheet from your code, the macro will run for the current ActiveSheet in all of Excel instead of only looking within the workbook that contains the code.

  4. #4
    Registered User
    Join Date
    07-03-2017
    Location
    Guymon, Oklahoma, USA
    MS-Off Ver
    Office 365, 2016
    Posts
    6

    Re: Macro only executes in Personal Macro Book

    Awesome! Yes it worked exactly how I wanted it! Thank you mehmetcik for fixing my code! And thank you brant.wheeler for explaining what was changed. I'm still new to the vba coding and I usually just record my macros but doing that limits me. Slowly but surely I will get better. Thanks again to both of you for your help!

+ 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] Why does macro work in one book, but not in personal.xlsb?
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2018, 11:44 AM
  2. Problem in Personal Macro Book
    By okat in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2017, 09:55 AM
  3. How to not show Personal macro book in every workbook VBA Project
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2017, 01:20 PM
  4. Macro only works in personal macro book
    By donkey_uk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2014, 11:10 AM
  5. Stop macro looking at personal book when not told to
    By cooket4 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-27-2012, 11:48 AM
  6. Macro that executes upon Open
    By jerem in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-18-2009, 10:55 PM
  7. Macro code to remove a macro after it executes
    By Charles in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2006, 08:15 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