+ Reply to Thread
Results 1 to 5 of 5

Use Target in standard module

  1. #1
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Use Target in standard module

    I have 5 spreadsheets with dozens of sheets on each. There are events such as selection_change, activate - example below:

    Please Login or Register  to view this content.
    The problem is that I am having to update around 100 sheets' code every time I change it - it is the same in all of them. To avoid this, I have condensed the worksheet code into the following:

    Please Login or Register  to view this content.
    So now I call subs from a module in each workbook, and only have to update 5 modules. I have managed to get them all to work, except for the one that involves Target - I can't use it in standard modules or find a way to pass the variable to a standard module.

    Any suggestions on how to use Target in a standard module (whether it's even possible), or how to better manage code in multiple sheet modules will be much most welcome.

    Thanks in advance.

    Antony.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Use Target in standard module

    Target is just a Range Object, why can't you pass it as a parameter?

    Alternatively, you could use the:
    Please Login or Register  to view this content.
    Sub in the ThisWorkbook Module

  3. #3
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Use Target in standard module

    Good point about the ThisWorkbook Module, I could create exceptions for the sheets that I don't want affected with IF statements - I should have thought about that really!

    As for using Target, I can't figure out how to pass it to a standard module - how would you do that?

    Many thanks for your suggestions

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Use Target in standard module

    Something like:
    Module code
    Please Login or Register  to view this content.
    SheetCode:
    Please Login or Register  to view this content.
    But tbh I'd use the ThisWorkbook approach

  5. #5
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Use Target in standard module

    Thanks again - will give it a go, but will probably follow your advice and us ThisWorkbook.

+ 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