I would like to achieve the following:

A1     A2     A3     A4      -> row 1
1      1      1      45      
              2      30      
              3      30
1      1      4      45
              5      30
                             ...
1      1    254      45
              1      30
              2      30
1      2      3      45
                             ... 
1    254    254      45
              1      30
              2      30
2      1      3      45
                            ...
3    189     12      45    -> up to approx row 250540

A2 should set a 1 from line 2 onwards in every three lines until a 254 was reached for the first time in A3. Then with the next setting (after 254 in A3) the 1 must be incremented and jump to 2 (A2). If the 254 in A2 is reached, it has to jump back to 1 and the 1 in A1 jumps to 2.

so far so good (from user: lupo1 from the ms-office-forum):

A1: =LET(n;250000;WAHL(SEQUENZ(;4);
WENN(REST(SEQUENZ(n);3)=1;KÜRZEN(SEQUENZ(n;;0;1/254^2)+1);"");
WENN(REST(SEQUENZ(n);3)=1;KÜRZEN(SEQUENZ(n;;0;1/254^1)+1);"");
REST(SEQUENZ(n;;0);254)+1;
INDEX({45.30.30};REST(SEQUENZ(n)-1;3)+1)))



WENN = IF, 
MOD = REMAIN, 
SEQUENZ = SEQUENCE, 
KÜRZEN = TRUNC,
Now to real question:

One thing doesn't work yet: Column A2 counts beyond 254, but should always jump back to 1 after 254. How do I implement this in the giving code?