简体   繁体   中英

Create Dynamic Array Spill-down with Adjusting Cell References

I am attempting to create a dynamic array spill-down with cell references that adjust as the array spills down.

Say I place 10 in cell A1 and in A2 I enter:

=IF(ROWS($1:1)>9,"",LN(10+A1^2))

and manually copy this downwards. The A1 reference will adjust as I copy downwards. So the formula in A3 will refer to the value in A2 . The formula in A4 will refer to the value in A3 , etc.:

在此处输入图片说明

But this is manual rather than dynamic. Another manual formula that works is:

=IF(ROWS($1:1)>9,"",LN(10+INDEX(A:A,ROWS($1:1))^2))

The only way I have succeeded is to use VBA:

Public Function propr(r As Range, N As Long)
    Dim arr, i As Long
    
    If N = 1 Then
    propr = Application.WorksheetFunction.Ln(10# + r.Value ^ 2)
         Exit Function
    End If
    
    ReDim arr(1 To N, 1 To 1)
    arr(1, 1) = Application.WorksheetFunction.Ln(10# + r.Value ^ 2)
    For i = 2 To N
        arr(i, 1) = Application.WorksheetFunction.Ln(10# + arr(i - 1, 1) ^ 2)
    Next i
    propr = arr
End Function

But I want a formula rather than a UDF.

What I have tried:

=LN(10+INDEX(A:A,SEQUENCE(9))^2)

This generates a circular reference warning:

在此处输入图片说明

This should be really easy, but I am not seeing it.

If you turn "Iterative Calculation" on, and reference the rows you want to fill, that will solve the Circular reference problem and your formula will Spill.

Also the If is not needed. In A2 use (of course you can use other techniques to define the range, eg INDEX )

=LN(10+A1:A9^2)

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM