Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:39:10+00:00 2026-06-15T09:39:10+00:00

Examples: Say I have several 1D arrays, such as A, B, and C: A

  • 0

Examples:
Say I have several 1D arrays, such as A, B, and C:

 A    B    C
---  ---  ---
 2    4    99
 3    5    37
 4    6    42
      7

I want to use a formula to pad each of these arrays (which are named ranges) so they have the same number of rows. (Edited, to provide a more complete explanation:) I would also like to be able to shift the starting position of each array by a specified number of rows. Here is an example output, where I’m shifting A by two, B by three, and C by one position:

 A'   B'   C'
---  ---  ---
 0    0    0
 0    0    99
 2    0    37
 3    0    42
 4    4    0
 0    5    0
 0    6    0
 0    7    0

So the “formula” (really a combination of multiple existing standard formulas) to pad one of the arrays would effectively have four inputs: the original array name/range, the number of values to pad at the beginning of the original array, the number to pad at the end, and the padding value (i.e. 0, NA(), etc.).

Initial approach:
My first attempt was to concatenate the three array sections (beginning padding array, original array, and ending padding array) into one array like this:

=INDIRECT("{" & IF(_NPadBegin>0, REPT(_PadVal&",", _NPadBegin-1) & _PadVal&",", "") & _ArrayName & IF(_NPadEnd>0, "," & REPT(_PadVal&",", _NPadEnd-1) & _PadVal, "") &"}")

(where the variables with underscores are named ranges for the four inputs)

However, it doesn’t seem possible to build an array like this. I’ve searched for other methods to combine 1D arrays using a formula, but came up empty.

Another approach might be to create an array of the final desired length and initially populate it with the padding value. For example, create an A’ array with eight rows of 0. (I can do this step in a dynamic formula.) Then you could overwrite the values in this initialized array with the original array, making sure to shift the original array to the correct location. For example, overwrite the 0 values in rows 2 through 4 of A’ with the values of A. (I can’t figure out how to do this second step…)

Background:
I have multiple 1D arrays of data (generated using dynamic named ranges) that I would like to plot together on a single line chart. The arrays have differing lengths however, so I need to pad each array with a certain number of NA() values at the beginning/end of the array. They also need to be “lined up” based on an index.

It probably wouldn’t be too difficult to achieve this in VBA, but I’d prefer a (non-user-defined) formula-based solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:39:11+00:00Added an answer on June 15, 2026 at 9:39 am

    If you have values 2, 3, and 4 in A2:A4 try this formula

    =IF(COUNTIF(A2:A4,ROW(INDIRECT("1:"&D2))-1),ROW(INDIRECT("1:"&D2))-1,0)

    where D2 contains the number of values (8 in your example).

    That will return this array

    {0;0;2;3;4;0;0;0}

    assumes that number series starts at zero – the zero at the end of the formula is the “padding value”, change as required

    OK as per comments you can do that with this array formula

    =IF((ROW(INDIRECT("1:"&NPadBegin+NPadEnd+ROWS(_ArrayName)))>NPadBegin)*(ROW(INDIRECT("1:"&NPadBegin+NPadEnd+ROWS(_ArrayName)))<=ROWS(_ArrayName)+NPadBegin),N(OFFSET(_ArrayName,ROW(INDIRECT("1:"&NPadBegin+NPadEnd+ROWS(_ArrayName)))-1-NPadBegin,0,1)),PadVal)

    assumes that _ArrayName is a vertical 1D array

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have several large arrays of variables (which generally are strings), and you
I have several hosts from which i want to do the same query. So
I have a function that updates several tables. As an example, let's say it
Let's say I have the following 4 tables (for examples' sake): Owners, Trucks, Boxes,
To use as an example: lets say that I have 2 EditText s and
i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update
Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
While looking into the IndexedDB API, I have found several examples of event handlers
First I want to say that I have looked at stackoverflow and highcharts forum,
Let's say I have a class Collection which holds a list of Items. public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.