+ Reply to Thread
Results 1 to 10 of 10

Having a Subscript issue on Worksheet rename code

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Having a Subscript issue on Worksheet rename code

    On the following code, I get to the line:
    Please Login or Register  to view this content.
    And then I get the error Subscript out of range. Can anyone identify the issue? Is it a problem with the rename of the sheet or the syntax?


    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Having a Subscript issue on Worksheet rename code

    Hi, pynergee,

    is it really
    Please Login or Register  to view this content.
    as you rely on ActiveWorkbook thereafter.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Re: Having a Subscript issue on Worksheet rename code

    It ran through two with this fix, but then on the third, it gave the same subscript out of range error on the With "wbNew.Worksheets("CDM PACKAGING") line. I'm going to try to find the file it attempted to modify to see if there are any issues within there that could have caused this.

  4. #4
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Re: Having a Subscript issue on Worksheet rename code

    It actually stops at the second. It writes the "ID Card Required" line and then gives the error, but in the resulting file, the two ranges are replaced.

    It does not close the second workbook however so it doesn't seem like it gets to the wbNew.Close True line.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Having a Subscript issue on Worksheet rename code

    Hi, pynergee,

    you have the file and can have a look at the workbook - I only get the information from you

    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Re: Having a Subscript issue on Worksheet rename code

    I have attached the sample after operation, and another example of before. The code is stopping on the "Sample", and "Sample2" is the sample before the code goes through.

    I am running it from a blank workbook.
    Attached Files Attached Files

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Having a Subscript issue on Worksheet rename code

    Hi, pynergee,

    if I open up Sample2.xlsm the code runs through just smoothly on my system - could you please indicate at which line the code stops if you run it?

    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Re: Having a Subscript issue on Worksheet rename code

    Sample2 works fine for me as well, it is getting hung up at the With statement in Sample1. It is a large directory, so there may be multiple issues similar to this. I am unsure of why it doesn't work for sample 1. It will just get stuck on this and will not close the workbook, so I'm assuming it isn't going all the way through for that part specific.

  9. #9
    Registered User
    Join Date
    05-28-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    90

    Re: Having a Subscript issue on Worksheet rename code

    I attached a "virgin" sample.
    Attached Files Attached Files

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Having a Subscript issue on Worksheet rename code

    Hi, pynergee,

    my last try for tonight:
    Please Login or Register  to view this content.
    There may be code added in case that the sheet canīt be found but thatīs secondary by now if the code still hangs.


    Ciao,
    Holger

+ 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. Replies: 7
    Last Post: 08-06-2013, 02:23 PM
  2. [SOLVED] 'Runtime Error 1004' when trying to Rename Worksheet using vba code
    By Raporter65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:43 PM
  3. Run-time error '9' Subscript out of range issue..
    By jdgwebdev in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-26-2013, 11:37 AM
  4. VBA code to Copy and Rename Worksheet
    By LampCommandr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2010, 07:19 PM
  5. [SOLVED] Subscript out of range ... sometimes! (Same code unpredictable re
    By Dennis in forum Excel General
    Replies: 3
    Last Post: 08-11-2005, 10:05 AM

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