+ Reply to Thread
Results 1 to 6 of 6

Nested Loop

  1. #1
    Registered User
    Join Date
    06-26-2018
    Location
    Perth
    MS-Off Ver
    2016
    Posts
    18

    Nested Loop

    Hi all,

    I am trying to write write a VBA program which uses a bi-linear interpolation calculator (references another worksheet) to populate the range R4:R18. I wish to take each value in the range Q4:Q18 and follow the following process....

    1) Take the first cell in range Q4:Q18 and paste into cell B25. This then calculates the interpolated value in cell B22
    2) Let cell R4 = cell B22.
    3) Repeat process for each cell in Range Q4:Q18 which will output in the adjacent range R4:R18

    I am sure there is a much more efficient way than what I have been trying i.e. pasting values etc. I have my VBA attempt in the editor window.......Hope someone out there can help me

    Regards,
    Jackson
    Attached Files Attached Files
    Last edited by Jackson2806; 01-07-2020 at 06:25 PM. Reason: Solved

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested Loop

    Untested but, in principle:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


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

    Re: Nested Loop

    Some quick comments:
    Is used "i" as index so it is certainly an integer and in next statement it is a range !!
    Please Login or Register  to view this content.
    There is some selections which takes time
    Please Login or Register  to view this content.
    can be changed to
    Please Login or Register  to view this content.
    Formula in B22 =FORECAST($C$7,B20:B21,$C$16:$C$17)
    could be prepared in the macro to reduce access time

    Finally to go really faster you have to work in memory (with tables ) and avoid any Pseudo range

    Can you pepare a display showing the final result to check the macro
    - Battle without fear gives no glory - Just try

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested Loop

    Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  5. #5
    Registered User
    Join Date
    06-26-2018
    Location
    Perth
    MS-Off Ver
    2016
    Posts
    18

    Re: Nested Loop

    Hi TMS,

    Thank you very much for your response. Ran this code this morning and it worked perfectly. Simple and elegant!

    Regards,
    Jackson

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Nested Loop

    You're welcome.

    Simple and elegant!
    That's me

+ 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. Need help with nested IF loop!
    By TropheusX in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-27-2017, 03:13 PM
  2. [SOLVED] For Loop nested in For Each Loop - Use For Each's [item] as row reference
    By Schluensen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2014, 11:37 PM
  3. [SOLVED] Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2014, 09:32 AM
  4. Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2014, 04:59 PM
  5. VBA Nested For Loop
    By jbuckets in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-15-2012, 10:49 PM
  6. Next without For error in nested loop - Escaping a Nested Loop?
    By BeneRich in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2012, 06:38 PM
  7. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 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