+ Reply to Thread
Results 1 to 4 of 4

How can I develop a macro so that it runs in one xls (not xlsm) worksheet only?

  1. #1
    Registered User
    Join Date
    10-21-2012
    Location
    Warwickshire, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    How can I develop a macro so that it runs in one xls (not xlsm) worksheet only?

    I would like to develop a macro in a test workbook so that I do not risk messing up my live data. I would then like to move that macro to the live worksheet and define a QAT Icon which is only visible in the live worksheet. The final result should be an xls file which I can send to other people / computers so that the Macro works on these other systems. I can do the development with Either Excel 2007 or Excel 2010 but ideally the final result should run in both environmets.

    I have got terribly confused trying to do this and have failed miserably. Can anyone give me some clear instructions on how to do this please?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: How can I develop a macro so that it runs in one xls (not xlsm) worksheet only?

    Sounds like you need a line at the start of the macro to test the name of the active workbook and then exit immediately if it is not the one desired.
    Martin

  3. #3
    Registered User
    Join Date
    10-21-2012
    Location
    Warwickshire, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How can I develop a macro so that it runs in one xls (not xlsm) worksheet only?

    Do I assume from what you say Martin that all Macros are public and the only way to stop them being executed in the wrong workbook is to do the test you suggest?
    If all macros are public does that mean that anytime I send a workbook to someone else they get any/all macros I may have written?

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How can I develop a macro so that it runs in one xls (not xlsm) worksheet only?

    Since Martin doesn't seem to be around...

    Quote Originally Posted by Bernard46 View Post
    Do I assume from what you say Martin that all Macros are public and the only way to stop them being executed in the wrong workbook is to do the test you suggest?
    Essentially yes, but with that being said, the user would have to have a way to run the macros.

    Quote Originally Posted by Bernard46 View Post
    If all macros are public does that mean that anytime I send a workbook to someone else they get any/all macros I may have written?
    They are only going to see the macros within that workbook, but not any stored in your personal.xlsb.

    Before sending the workbook out you could protect the VBE environment, but caution, don't forget this password or there may be trouble.
    HTH
    Regards, Jeff

+ 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