+ Reply to Thread
Results 1 to 8 of 8

VBA that works in Excel 2010 but not Excel 2016

  1. #1
    Registered User
    Join Date
    02-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    33

    VBA that works in Excel 2010 but not Excel 2016

    Hi,

    Can someone advise me on a workaround for this issue?

    This snippet of VBA code below works fine in Excel 2010, but crashes with no debug button in Excel 2016.

    If I explicitly state the workbook to Activate, it works fine, but 2016 doesn't seem to like the workbook name as a variable. Is there a way to code around this without explicitly stating the workbook name to activate?

    Thanks

    =========================
    mycurrsup = Range("mycurrsup")
    Windows(mycurrsup).Activate
    =========================

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: VBA that works in Excel 2010 but not Excel 2016

    So mycurrsup is a Named Range (single cell) containing the name of a workbook as text, correct? What is the error message?
    Last edited by leelnich; 07-23-2017 at 11:13 PM.

  3. #3
    Registered User
    Join Date
    02-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: VBA that works in Excel 2010 but not Excel 2016

    Yes "mycurrsup" is a named range single cell containing the name of a workbook as text and there is no problem with this code in Excel 2010.

    I'm a bit confused now though, as I couldn't recall the error message so went to test it on someone's laptop that uses Excel 2016 and it didn't fail during that test.

    Certainly, I avoided the error on the first person's laptop by explicitly stating the name of the workbook in the VBA code and I know this does happen, but it appears it doesn't happen on EVERYONE'S Excel 2016.

    Maybe there's a setting in Excel 2016 that is causing the problem???

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA that works in Excel 2010 but not Excel 2016

    What's the name of the workbook you are trying to activate?

    Are you using the full workbook name including the file extension?

    PS Why are you using Windows(...) and now Workbooks(...)?
    If posting code please use code tags, see here.

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: VBA that works in Excel 2010 but not Excel 2016

    I see you didn't fully qualify the Range reference. Make sure the right worksheet/workbook is active or you won't get the right cell.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

  6. #6
    Registered User
    Join Date
    02-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: VBA that works in Excel 2010 but not Excel 2016

    Quote Originally Posted by Norie View Post
    What's the name of the workbook you are trying to activate?

    Are you using the full workbook name including the file extension?

    PS Why are you using Windows(...) and now Workbooks(...)?

    The name of the workbook is "Cattle 2017 v3.xlsm" (obviously without the quotes).

    Yes, I'm using the full filename with extension.

    Windows(...) vs Workbooks(...) - what is the difference? I've always used "Windows". Is there a distinction, and if so, what is it? Should I be using it?

  7. #7
    Registered User
    Join Date
    02-29-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: VBA that works in Excel 2010 but not Excel 2016

    Quote Originally Posted by leelnich View Post
    I see you didn't fully qualify the Range reference. Make sure the right worksheet/workbook is active or you won't get the right cell.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Hi Leelnich.

    What does "fully qualify the Range reference" mean?

    Is it something new to Excel 2016?

    Thanks

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: VBA that works in Excel 2010 but not Excel 2016

    No, I just meant reference a specific workbook and/or worksheet so VBA doesn't assume you mean whatever Worksheet is currently active.
    Please Login or Register  to view this content.
    This might not be necessary, depending on how you defined mycurrsup (or the correct sheet is currently active.)
    Last edited by leelnich; 07-24-2017 at 02:50 AM.

+ 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. [SOLVED] MS Excel 2010 to MS Excel 2016 Compatibility Issue
    By N323100 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2017, 07:06 AM
  2. Range (Is not working in excel 2010, but it is in excel 2016)
    By Luisfca in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-25-2017, 06:00 AM
  3. 2010 Macro not working in 2016 Excel
    By porepiga in forum Excel General
    Replies: 7
    Last Post: 04-18-2017, 12:11 PM
  4. Opening Excel 2010 in 2016 causes double images
    By tlshook in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2016, 12:48 PM
  5. [SOLVED] today() in Excel 2010 32 bit vba returns different value than Excel 2016 64bit
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-10-2016, 12:34 PM
  6. Excel 2010 vs. Excel 2016 Slicer
    By mycon73 in forum Excel General
    Replies: 0
    Last Post: 03-18-2016, 12:40 AM
  7. UDT passing byref works in WinXP Excel 2010 fails on Win7 64 bit Excel 2010 32 bit
    By MarkInKeizer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-09-2014, 11:49 AM

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