Consulting

Results 1 to 11 of 11

Thread: Let and Lambda

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location

    Let and Lambda

    I have to admit that, whilst I am not convinced that these are the way to go for Excel (most Excel users don't want to 'program' Excel, and most 'useful' Lambda functions that I see are pretty complex, and I find that I struggle to understand Lambda functions that I wrote when I revisit them), I am using them an awful amount in my own workbooks.

    One thing I especially like to do with Let formulae is to declare my variables up top, rather than in the body of the function. In a very simple example, rather than
    =LET(res, FILTER($A$1:$A$500, $B$1:$B$500="Transfer"),
             res)
    I would write
    =LET(method, "Transfer",
             res, FILTER($A$1:$A$500, $B$1:$B$500=method),
             res)
    One issue I have come up against though is that I don't see to be able to setup a table variable in this way. Take this example formula
    =LET(tx, tblTransactions,
              method, "Transfer",
              tx_date, TODAY(),
              res, FILTER(tx[Date], (tx[Method]=method)*(tx[Date]>=tx_date)),
              res)
    I could use INDIRECT for the table, but I don't want to do that.

    I could also define each of the table columns separately and reference those, but I was wanting to have a single point defining the table.
    Does anyone else have this issue? Has anyone cracked it.
    Last edited by Bob Phillips; 04-02-2024 at 09:15 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •