+ Reply to Thread
Results 1 to 7 of 7

Can not change Sheet codename

  1. #1
    Registered User
    Join Date
    02-20-2020
    Location
    Ukraine
    MS-Off Ver
    Microsoft Office for Mac, 16.34
    Posts
    13

    Can not change Sheet codename

    Hi,

    I found on SO nice function to get worksheet by its codename:
    Please Login or Register  to view this content.
    It works perfectly, but if I change default sheet codename, for example, from "Sheet5" to "Variables" it throws an error "Can not run macro. The macro may not be available in this workbook or all macros may be disabled".
    I'm coding on MS Office for Mac, maybe there is some issue, I can't test it on Windows, right now

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,726

    Re: Can not change Sheet codename

    What's the purpose of the function?
    I really don't see the need for the function to get worksheet by code name...

    You can simply use worksheet code name like below... assuming Variables is set as it's code name.
    Please Login or Register  to view this content.
    If you need to pass that on to another procedure etc, you can declare it as public/global variable.
    “Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.”
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    02-20-2020
    Location
    Ukraine
    MS-Off Ver
    Microsoft Office for Mac, 16.34
    Posts
    13

    Re: Can not change Sheet codename

    It's like a some sort of security if few workbooks are opened and sheets have same names.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,726

    Re: Can not change Sheet codename

    I see. In general I don't recommend using sheet code name for code that doesn't run on the workbook containing the code itself. Specifically for that reason.

    You should use Sheets(Index#) or Sheets("SheetName") both of which can and should be qualified with workbook object.
    Please Login or Register  to view this content.
    I tested the function, but had no issue on my end.
    0.JPG

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,312

    Re: Can not change Sheet codename

    What exactly throws the error - that isn't a macro?
    Rory
    I drink, and I know things

  6. #6
    Registered User
    Join Date
    02-20-2020
    Location
    Ukraine
    MS-Off Ver
    Microsoft Office for Mac, 16.34
    Posts
    13

    Re: Can not change Sheet codename

    Oh, I have dew updates:

    1) rename sheet codename - works perfectly on Windows (I've tested few minutes ago) and throws and error on Mac, so it's kinda an answer to my question
    2) it would be very good to refer to sheets by name, but, unfortunately, I need to rename some sheets dynamically, don't ask why

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    2016 primarily
    Posts
    6,312

    Re: Can not change Sheet codename

    Changing the code name works fine in 16.35 for me.

+ 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. Getting Sheet name from codename?
    By aquixano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2017, 01:42 AM
  2. [SOLVED] VBA sub for sheet with codename
    By Roadhouse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2016, 04:00 PM
  3. Change Sheet CodeName and try to access it during running code does not work
    By Anke in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-24-2015, 10:37 AM
  4. [SOLVED] Sheet Codename
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2015, 12:34 PM
  5. [SOLVED] Selecting sheet by codename in a multi sheet code
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-18-2013, 10:46 AM
  6. Get sheet (CodeName) not .Name
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2010, 01:54 PM
  7. change sheet codename
    By Gary Keramidas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2006, 09:00 PM

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