+ Reply to Thread
Results 1 to 6 of 6

Public Variables

  1. #1
    Registered User
    Join Date
    07-14-2014
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    26

    Public Variables

    This problem is not consistent. Sometimes the code works sometimes it doesnt i cannot track down the problem...

    In the same module i run the following code:

    I first run:

    Please Login or Register  to view this content.
    Then I use those variables here:

    Please Login or Register  to view this content.
    It throws:

    " runtime error 9, subscript out of range"

    What am I doing wrong. They are public variables?!
    Last edited by iamGreenhorn; 07-22-2014 at 04:16 AM.

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

    Re: Public Variables

    And there's definitely sheets witht the names specified in curMI and curOOT?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    07-14-2014
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    26

    Re: Public Variables

    It creates those sheets

    But It throws the error here:
    Please Login or Register  to view this content.
    It is suppose to stop the sub before it creates a blank sheet and throws a already exists error

  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: Public Variables

    If there isn't a sheet with the name the same as the value in curMI you will get a subscript out of range error.

  5. #5
    Registered User
    Join Date
    07-14-2014
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    26

    Re: Public Variables

    I used to use the curOOT variable and set it to a sheet and it would throw the same error..
    How else do you check if a sheet exists without this error, this is the best i could find online without getting super complicated.

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

    Re: Public Variables

    There are lots of ways to check if a sheet exists, here's one.
    Please Login or Register  to view this content.

+ 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. Public variables
    By Tomski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2006, 10:20 AM
  2. [SOLVED] Public Variables
    By [email protected] in forum Excel General
    Replies: 6
    Last Post: 09-12-2005, 12:05 PM
  3. [SOLVED] Public Variables
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2005, 12:05 PM
  4. Public Variables
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2005, 07:06 AM
  5. Public variables
    By jcp29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2005, 07:10 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