+ Reply to Thread
Results 1 to 7 of 7

For Loops and Arrays

  1. #1
    Registered User
    Join Date
    06-19-2019
    Location
    Toronto
    MS-Off Ver
    Professional 2016
    Posts
    4

    For Loops and Arrays

    Good Morning,

    I am having a problem creating a for loop that iterates through a range of values while doing a function on every row.

    The problem at hand:
    If I have some function - Performance = ( 1 - (Part1IdealRate * Part1PartsProduced) ) + ( 1 - (Part2IdealRate * Part2PartsProduced) ) + ...etc how would I go about applying this?
    My initial attempt involved just iterating over the entire range and applying the formula onto the rows, specifying the cells such that

    Please Login or Register  to view this content.
    This value is then send to an array
    Please Login or Register  to view this content.
    Then the array is redimmed
    Please Login or Register  to view this content.
    Everytime I run this it yields an error at the Redim - Error 9: Subscript out of range .

    Heres the entire portion of the code:

    Please Login or Register  to view this content.
    Any help would be appreciated thanks!

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: For Loops and Arrays

    You need to specify Lower bound.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-19-2019
    Location
    Toronto
    MS-Off Ver
    Professional 2016
    Posts
    4

    Re: For Loops and Arrays

    Thank you very much, I was struggling to figure out my problem

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: For Loops and Arrays

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    06-19-2019
    Location
    Toronto
    MS-Off Ver
    Professional 2016
    Posts
    4

    Re: For Loops and Arrays

    One more quick question - I realized now that SumProduct, well takes the sum. Thats all fine and dandy except that isn't the desired result I would like, is there an Application.WorksheetFunction.CustomFunction??? Where I can place a custom function similar to the row-wise PValue Formula I have running on each row?

    Nevermind - I realized I can just get rid of the WorksheetFunction altogether
    Last edited by Adrian Hudson; 06-19-2019 at 09:26 AM.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: For Loops and Arrays

    Can you explain what you expect the below line to do?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-19-2019
    Location
    Toronto
    MS-Off Ver
    Professional 2016
    Posts
    4

    Re: For Loops and Arrays

    I thought I needed that in order to apply the inner function I have to the Array - I have realized now though that essentially removing the WorksheetFunction "SumProduct" now accomplishes the same thing just sans summing the result value.

+ 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] Comparing two arrays without using loops
    By Stefan22 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-26-2016, 03:58 PM
  2. [SOLVED] Replace loops with arrays
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2016, 10:11 AM
  3. [SOLVED] Loops and arrays
    By LadyB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2013, 04:28 PM
  4. VBA Loops + Arrays
    By Kengh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-26-2010, 07:41 PM
  5. Loops and Arrays
    By v2jtb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2010, 12:09 PM
  6. slow for loops ... better way using arrays or something?
    By wdeleo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2006, 10:35 AM
  7. VBA excel using arrays and loops
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2006, 08:55 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