SOLVED

How to assign and reuse a temporary name within a formula?

Brass Contributor

If you have a complex formula, e.g. (Sorry for German language. Should be understandable anyway:(

=WENN(ISTZAHL(
   VERGLEICH(FALSCH;BEREICH.VERSCHIEBEN(daten;1;0;ZEILEN(daten)-1)>=daten;0));
   "Datum nicht sortiert! Z(" & 
   VERGLEICH(FALSCH;BEREICH.VERSCHIEBEN(daten;1;0;ZEILEN(daten)-1)>=daten;0)+1+HeadRow & ")";"")

 then it would be nice to assign a temporay name tmp and reuse it. This would look like:

=WENN(ISTZAHL(
   tmp=VERGLEICH(FALSCH;BEREICH.VERSCHIEBEN(daten;1;0;ZEILEN(daten)-1)>=daten;0));
   "Datum nicht sortiert! Z(" & 
   tmp+1+HeadRow & ")";"")

Is this possible?

 

ps: This example searches a column daten for the first not ascending element.

2 Replies
best response confirmed by Werner_Geiger (Brass Contributor)
Solution
Yes it is! Have a look at the LET function (does require Office 365 though): https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999

@Jan Karel Pieterse 
Great, thanks a lot! This does the job:

=LET(tmp; VERGLEICH(FALSCH;BEREICH.VERSCHIEBEN(daten;1;0;ZEILEN(daten)-1)>=daten;0);
 WENN(ISTZAHL(tmp);"Datum nicht sortiert! Z(" & tmp+1+HeadRow & ")";""))

 

I think I read about this (new) LET before but forgot about it.

1 best response

Accepted Solutions
best response confirmed by Werner_Geiger (Brass Contributor)