+ Reply to Thread
Results 1 to 6 of 6

Running LET() function as a loop

  1. #1
    Registered User
    Join Date
    11-20-2022
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    3

    Running LET() function as a loop

    I have a long LET() function where I define a number of variable but with one of them being a range. Subsequently, I have a number of calculations which depend on the range but I want to make sure that all of the calculations are run fully with the first number in the range before the calculations are done again with the second number in the range. The formula works when calculating with a single number but not with the range. How can I solve this? (I don't have access to LAMBDA, SCAN etc. due to semi annual channel)

    Example:
    Range {1,3,5}
    when range=1, result=20
    when range=3, result=50
    when range=5, result=26

    So I want the result of the formula being {20,50,26}, how do I ensure this?

    Formula looks like this where I would like to run a loop for the second part based on the range from "peaks_position"


    Please Login or Register  to view this content.
    Last edited by FDibbins; 11-21-2022 at 01:33 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Running LET() function as a loop

    Moly, welcome to the forum.

    Unfortunately, there are 2 problems with your post....

    1. you need to include code tags around your code.

    Please take a moment to add the tags. 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, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, 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

    (I have added them for you - this time

    2. it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (I have added the link for you - this time... https://www.mrexcel.com/board/thread...-loop.1222696/ )
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Running LET() function as a loop

    I don't have access to LAMBDA, SCAN etc. due to semi annual channel
    I think you should have MAP ... LAMBDA because MAP ... LAMBDA is introduced in december 2020.

    Please try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and replace in the formula the value(s) that should be respectively 1, 3 and 5 by x.
    In stead of x you can also choose another name.

    EDIT: Attached a workbook with an example map:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Example 2; Nice to know its also possible to add more parameters. For example
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 11-21-2022 at 02:35 AM. Reason: attached a 2nd example with 2 parameters

  4. #4
    Registered User
    Join Date
    11-20-2022
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    3

    Re: Running LET() function as a loop

    Thanks! Appreciate the help

  5. #5
    Registered User
    Join Date
    11-20-2022
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    3

    Re: Running LET() function as a loop

    Quote Originally Posted by HansDouwe View Post
    I think you should have MAP ... LAMBDA because MAP ... LAMBDA is introduced in december 2020.

    Please try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and replace in the formula the value(s) that should be respectively 1, 3 and 5 by x.
    In stead of x you can also choose another name.

    EDIT: Attached a workbook with an example map:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Example 2; Nice to know its also possible to add more parameters. For example
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks for the reply but unfortunately, I do not have access to MAP and LAMBDA yet through my corporate account. Is there a way to do it without those?

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,419

    Re: Running LET() function as a loop

    If you don't have a MAP LAMBDA in EXCEL 365 then it looks like your version of EXCEL 365 is at least 2 years old.

    In that case you can try to replace the value that should be 1, 3 or 5 respectively with {1,3,5} in your formula.
    [And confirm your formula with CTRL+SHIFT+ENTER].

    But unfortunally that doesn't always work.
    That can only work for functions that are normally only offered a single value in the place where you replaced this value by {1,3,5}.
    Last edited by HansDouwe; 11-21-2022 at 03:22 AM.

+ 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. Running a loop
    By jptierney in forum Excel General
    Replies: 4
    Last Post: 08-14-2021, 10:19 AM
  2. [SOLVED] Loop not running through
    By bk23 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2019, 04:08 AM
  3. [SOLVED] Loop keeps running
    By jduong93 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2016, 07:30 PM
  4. [SOLVED] Running Loop in an Array
    By Jiptastic in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 06:15 PM
  5. Do loop not running
    By hattrick_123a in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-21-2011, 08:36 PM
  6. Loop not running
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2006, 10:26 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