简体   繁体   English

通过调整单元格引用创建动态数组溢出

[英]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:假设我在单元格A1 中放置10并在A2 中输入:

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

and manually copy this downwards.并手动向下复制。 The A1 reference will adjust as I copy downwards.当我向下复制时,A1 参考将调整。 So the formula in A3 will refer to the value in A2 .所以A3 中的公式将引用A2 中的值。 The formula in A4 will refer to the value in A3 , etc.: A4 中的公式将引用A3 中的值等:

在此处输入图片说明

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:我成功的唯一方法是使用 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.但我想要一个公式而不是一个 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 )A2使用(当然您可以使用其他技术来定义范围,例如INDEX

=LN(10+A1:A9^2)

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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