+ Reply to Thread
Results 1 to 6 of 6

Quickest way to get code onto every sheet?

  1. #1
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Quickest way to get code onto every sheet?

    I have the following macro in one worksheet of a workbook and I need it to run on every worksheet. I'm wondering if there is a way to revise the code and put it into the Workbook object and have it run on all sheets or if there is a macro I can use?

    Please Login or Register  to view this content.

    Thank you!
    Last edited by kirsty; 12-17-2010 at 08:43 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Quickest way to get code onto every sheet?

    You might try the Workbook_SheetSelectionChange
    in the ThisWorkbook module..
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Quickest way to get code onto every sheet?

    Thank you for the suggestion. I tried it, and I received this error message:

    Compile error:

    Procedure declaration does not match description of event or procedure having the same name.


    My code is now in the Workbook object and looks like:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Quickest way to get code onto every sheet?

    The code in the workbook module should be
    Please Login or Register  to view this content.

    Where did you get the argument "ByVal Target As Excel.Range" from?

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  5. #5
    Registered User
    Join Date
    10-18-2010
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2007
    Posts
    47

    Re: Quickest way to get code onto every sheet?

    Thank you Marcol! Works like a charm.

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Quickest way to get code onto every sheet?

    Happy to help.

    When using Sheet/Workbook Events, don't change the built in arguements.

    I am still interested how you arrived at "ByVal Target As Excel.Range" was it from some other application?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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