+ Reply to Thread
Results 1 to 5 of 5

Getting VBA Run time error '9' on only some machines

  1. #1
    Registered User
    Join Date
    09-28-2021
    Location
    Johannesburg, South Africa
    MS-Off Ver
    EXcel for Office 365
    Posts
    2

    Getting VBA Run time error '9' on only some machines

    I've created a macro to check text in a Purchase Order (Copied into a sheet "PO_Text") and return certain values from the text. The following code works well on a number of PC's, but not on some. When running the macro, I get the Runtime Error '9' Subscript out of range on the highlighted line. I've not been able to replicate the error on my PC and the users that experiences the issue work remotely, so difficult to do fault finding.

    Any ideas as to what the problem is are welcome.

    Please Login or Register  to view this content.
    Last edited by AliGW; 09-28-2021 at 05:40 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Getting VBA Run time error '9' on only some machines

    I suspect not all of the users have 365. Change xlFormulas2 to just xlFormulas
    Rory

  3. #3
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,208

    Re: Getting VBA Run time error '9' on only some machines

    Apart from changing xlFormulas2, I recommend that you write the code in such a way that it does NOT reference the active sheet by default (because there is no qualifier for Range, Cells, etc.). It happens that the code will not work then.
    Nor can it be optimistically assumed that the searched phrase will be found always. The day will come when she will not be found. Such a case should be programmed. I only gave a message and an exit from the procedure, but this is not always the correct approach to the problem, especially when the previous part of the macro has already made some changes to the workbook. I will not mention the lack of declarations of the variables used.
    Corrected code below
    Please Login or Register  to view this content.
    Artik

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,493

    Re: Getting VBA Run time error '9' on only some machines

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I've done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    09-28-2021
    Location
    Johannesburg, South Africa
    MS-Off Ver
    EXcel for Office 365
    Posts
    2

    Re: Getting VBA Run time error '9' on only some machines

    Thanks very much. That seemed to be the problem. The users were not on Office 365, but on Office 2017, so when I tested the original Macro on Office 2013, I could replicate the problem.

    I've then changed the xlFormulas2 to xlFormulas and the macro then worked perfectly!

+ 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] Production Calculator... work out time to produce and how many machines
    By pmw19800 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-08-2019, 12:21 PM
  2. 'Can't exit design mode' error when workbook opened on some machines only!
    By MathUKTeacher in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2015, 05:40 PM
  3. [SOLVED] Run-Time Error 1004 on Certain Machines
    By yay_excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2015, 01:32 PM
  4. Down time for machines at work in military time not adding up.
    By joshuawcolvey in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-02-2014, 11:08 AM
  5. run-time error ;2147023179 (800706b5) time automation error interface unknown
    By karthik72 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 09:31 AM
  6. Macro for finding Overlapping duration of all the machines in service at a time
    By welsel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2012, 06:12 AM
  7. Macros giving Run-time error '9' on all machines except mine
    By WinterCoast in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2008, 12:56 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