Share via

Variable array format

John Lacey 20 Reputation points
2026-02-27T16:05:13.8466667+00:00

How can I write an array with variable sizing.

E.G. Linest(A2:A10) where "10" can come from INDEX(C3, B2:B50)

Microsoft 365 and Office | Excel | For home | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Q&A Assist
    2026-02-27T16:05:25.25+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use INDEX (or another function) to build the row number, then wrap it in INDIRECT (or OFFSET) to create a variable range for LINEST.

    A typical pattern is:

    =LINEST(A2:INDEX(A:A, C3))
    

    Here, C3 contains the last row number (10 in the example), so A2:INDEX(A:A, C3) evaluates to A2:A10. This works directly in LINEST without needing an array constant.

    If the last row number is calculated from a range like B2:B50, put that result in a cell (for example in C3), then use the same pattern:

    =LINEST(A2:INDEX(A:A, C3))
    

    If a dynamic array constant is needed (for example, to multiply the LINEST result by {n,1} as in the example), the constant itself must still be typed explicitly, but the data range passed to LINEST can be variable as shown above.

    Remember that LINEST is an array function. In current Microsoft 365 versions, enter it normally and it spills. In earlier versions, select the output range and confirm with Ctrl+Shift+Enter.


    References:

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.