+ Reply to Thread
Results 1 to 6 of 6

Getting Subscript out of range error in the following code

  1. #1
    Registered User
    Join Date
    06-29-2017
    Location
    Mumbai
    MS-Off Ver
    2013
    Posts
    3

    Getting Subscript out of range error in the following code

    Sub MinFun()

    For n = 1 To UBound(MyResFT)
    If MinVal = MyResFT(n) Then
    n = n
    End If
    Next


    I want to assign value to n basis match between MinVal & MyResFT(n). Getting this error. Please help.

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Getting Subscript out of range error in the following code

    how do you populate MyResFT ?
    is it maybe a 2 dimensional array?
    eg
    Please Login or Register  to view this content.
    Im not sure what you are doing here though you seem to be changing n and trying to use it in a for loop how is that going to work (and you are assigning it to be itself)? don't you want to assign a different thing to be n? like maybe nn?
    Last edited by scottiex; 06-29-2017 at 12:52 AM.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Registered User
    Join Date
    06-29-2017
    Location
    Mumbai
    MS-Off Ver
    2013
    Posts
    3

    Re: Getting Subscript out of range error in the following code

    The Array's one dimensional.

    Declared as MyResFT()

    ReDim MyResFT(10)

  4. #4
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Getting Subscript out of range error in the following code

    OK I imagine we need the rest of the code then, as filling out that code doesn't seem to create an error.

  5. #5
    Registered User
    Join Date
    06-29-2017
    Location
    Mumbai
    MS-Off Ver
    2013
    Posts
    3

    Re: Getting Subscript out of range error in the following code

    When I debug it, here's where the error's reflected.

    MyResFT(n) = Sheets("Sheet3").Cells(myrow, 6)

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Getting Subscript out of range error in the following code

    kwadh, welcome to the forum.
    Please take a minut to read our forum rules.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    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, it also maintains VBA formatting.

    Click on Edit to open your thread, 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

    Also how do you fill MyRestFT ?
    Where do you determine myrow ?
    I guess we will need the entire code your using because now there are more questions then answers.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ 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] VBA 'convert date' code giving 'run time error 9 - subscript out of range'
    By seputus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2017, 07:43 PM
  2. Code is giving Runtime Error 9 Subscript out of range
    By clpickett3 in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 03-05-2015, 01:45 PM
  3. Error "Subscript out of range", cant seem to find where code is wrong
    By KeithMale in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2013, 07:07 PM
  4. [SOLVED] trying to understand why a code is not working "error 9 subscript out off range"
    By cdafonseca in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-09-2013, 12:33 PM
  5. [SOLVED] Can't debug this code. The Arrays are producing a Subscript out of Range error
    By seigna in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-06-2013, 05:14 PM
  6. Subscript out of range error & code not working
    By HP RodNuclear in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-01-2011, 03:53 PM
  7. Subscript out of range error using all possible combinations code
    By alisalamiii in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2010, 09:57 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