+ Reply to Thread
Results 1 to 4 of 4

Code fails when running under VMWare

  1. #1
    Forum Contributor
    Join Date
    08-05-2009
    Location
    Colorado Springs, CO
    MS-Off Ver
    Office 365
    Posts
    161

    Code fails when running under VMWare

    This block of code replaces a worksheet with one from a file. It runs fine when I'm at work, but trying to run it remotely using VMWare, it fails. Can I fix this?
    I get a runtime error 9/subscript out of range on the line below
    Set wsnew = wbnew.Sheets("Sheet1")

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,526

    Re: Code fails when running under VMWare

    Well, that must mean there is no "Sheet1" in the workbook being opened. You need to step through the code and determine a) what the filepath is, then b) check what filename is selected from the dialogue and then finally c) check that the file opened does have the Sheet1 in it.

    It may be that, in the Virtual Machine, the filepath takes you somewhere other than where you think it does.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    08-05-2009
    Location
    Colorado Springs, CO
    MS-Off Ver
    Office 365
    Posts
    161

    Re: Code fails when running under VMWare

    Well, the sheet name now has the name "Data" rather than "Sheet1", and I don't know how that came about, but Data works as well as Sheet1. Thanks for the tip.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,526

    Re: Code fails when running under VMWare

    You're welcome.

    You could use the Sheet's Code Name which would most likely be Sheet1. Then it doesn't matter if it gets renamed.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] ThisWorkbook.RefreshAll Fails Unless Running One Line at a Time
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-14-2017, 10:22 AM
  2. code works running in visual basic editor but not when running from Excel macro
    By smporco in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-06-2016, 05:44 PM
  3. [SOLVED] How to prevent worksheet code from running while Module Macro is running:
    By Chad Bateman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2015, 09:26 AM
  4. Code Fails Saving File
    By breader in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2013, 03:06 AM
  5. VBA code works in one SUB and fails in a different SUB
    By jcaskey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2013, 11:54 AM
  6. Code fails if ran more than once
    By Christy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-31-2005, 02:05 PM

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