+ Reply to Thread
Results 1 to 17 of 17

Subscript Out of Range Run Time Error 9: Please Help

  1. #1
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Subscript Out of Range Run Time Error 9: Please Help

    Hello,

    I'm trying to have the following calculation, Row I (Budget) - Row K (Expenses), populate the answer in a new column (O) for each row of data. The code I have written below gives me a run time error 9: Subscript out of Range and highlights the line starting with Answer5(counter, 1). Can anyone assist? Thanks

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    What do you want to do with statements?

    Please Login or Register  to view this content.
    At the end of the loop Dimension5 is equal to UBound(Budget, 1) +1
    Therefore you have to use UBound(Budget, 1) and not Dimension5 in next Statement

    Please Login or Register  to view this content.
    Last edited by PCI; 12-23-2014 at 05:01 PM.
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    I'm trying to set dimension 5 as having the capability to include both the range values of the budget and the expenses. I wasn't sure if I could or if I needed to create another dimension. I know dimensions are typically row x column, but I thought dimensions could be expanded beyond just 1 row and 1 column. I'm not sure if my approach is correct or not. Please let me know if this helps or if you need further information. Thanks for your reply

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    See next remake
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    What do you mean by " the capability to include both the range values of the budget and the expenses"
    A first think will be to have a range from
    the Maxi (LBound(Expenses, 1) , LBound(Budget, 1))
    to
    the Min (UBound(Expenses, 1) , UBound(Budget, 1))

  6. #6
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    That helped eliminate the run time error, thank you

    However, the data that's being calculated is not accurate. For example it's saying that $2,243.96 - $2,243.96 = ($0.96). Further, I can notice a trend occurring. Every time the answer should be = 0, it''s incorrectly putting the answer as the amount of cents in both the budget and expense (.96 as with the case above), and then making it negative. Every time the answer is anything other than 0, it's calculating correctly. Do you have any idea why this might be happening?

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    " the data that's being calculated is not accurate."
    Send your data to see what's up

  8. #8
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    My apologies, but what's the most effective way to send the data to you?

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    "$2,243.96 - $2,243.96 = ($0.96)."
    Yes of course because you are using
    Please Login or Register  to view this content.
    which truncate the Budget value removing digits after the "."
    Last edited by PCI; 12-23-2014 at 05:43 PM.

  10. #10
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    "the most effective way to send the data "
    see next steps to follow

    Reply To Thread
    Go Advanced
    Manage Attachments
    Add Files
    Browse
    ==> Select your file
    Upload
    Done

  11. #11
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    Interesting, nice catch. Any ideas on an alternative solution?

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    If you want to do a simple difference just do

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    Perfect, that's exactly what I needed. Thank you

    May I also ask, if I try to divide instead using the following:

    Please Login or Register  to view this content.
    I receive a run time error '11': division by zero. Do you know how I can fix this?

    Thanks again

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    In case Expenses(Counter, 1) = 0
    what is the result you want?

  15. #15
    Registered User
    Join Date
    12-22-2014
    Location
    Madison, WI
    MS-Off Ver
    MS Office 2013
    Posts
    33

    Re: Subscript Out of Range Run Time Error 9: Please Help

    Can it just resume with the next calculation?

    I tried "On Error Resume Next", but that didn't work.
    Last edited by Pauly723; 12-23-2014 at 06:09 PM.

  16. #16
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    Try

    Please Login or Register  to view this content.

  17. #17
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Subscript Out of Range Run Time Error 9: Please Help

    Another variation
    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. [SOLVED] Run-time error '9': subscript out of range - error occurs on multiple computers except one
    By BrettE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 11:19 PM
  2. Run Time Error 9: Subscript out of Range
    By DanManly in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 11-15-2012, 03:07 PM
  3. Run-time error '9' - Subscript out of range
    By mgphill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2012, 10:08 AM
  4. Run-time error '9': subscript out of range
    By nicko54 in forum Excel General
    Replies: 6
    Last Post: 02-02-2011, 09:08 PM
  5. VB Run-time error '9'; Subscript out of range
    By lisabethvw in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2009, 03:49 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