+ Reply to Thread
Results 1 to 4 of 4

Macro running on active sheet instead of sheet defined in macro

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    35

    Macro running on active sheet instead of sheet defined in macro

    Hi, I am having a problem with a macro that is supposed to run on a specific sheet(s) defined in the macro but is instead running on the active sheet and not the defined sheet(s). Can someone help me with this please? In the specific instance, there are 4 defined sheets but in other workbooks, I have as few as one. If the active sheet is one of the defined sheets I don't seem to have an issue but if I am on a sheet the macro should ignore, it still runs which is causing me problems. I could add a Worksheet.select but then I end up on a different tab every time I save (I have my macros running in a BeforeSave) which is less than ideal. Please help! Thanks.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro running on active sheet instead of sheet defined in macro

    You don't fully reference ranges in your code everywhere. For example this
    Please Login or Register  to view this content.
    should probably be like this
    Please Login or Register  to view this content.
    edit: unqualified references will always refer to active objects. Like active workbook, active worksheet, etc.

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    NY
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Macro running on active sheet instead of sheet defined in macro

    Thank you!!

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Macro running on active sheet instead of sheet defined in macro

    Glad to help.

+ 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