Excel:使用n倍常数创建数组 [英] Excel: creating an array with n times a constant

查看:65
本文介绍了Excel:使用n倍常数创建数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经逛了一会儿了,但是找不到我的问题的答案.

I have been looking around for a while but unable to find an answer to my question.

在Excel中,我可以使用哪种紧凑公式创建由重复 n 次的单个元素组成的数组,其中 n 是输入(可能是硬编码)?

In Excel, what compact formula can I use to create an array made up of a single element repeated n times, where n is an input (potentially hard-coded)?

例如,看起来像这样的东西(下面的公式不起作用,但是给出了我要寻找的东西的意思):

For example, something that would look like this (the formula below does not work but gives an idea of what I am looking for):

{={"Constant"}*3}

注意:我不是在寻找基于VBA的解决方案.

推荐答案

一个人可以将1:n空单元格连接到常数",以创建具有n个常数"项的字符串数组:

One could concatenating 1:n empty cells to the "Constant" for creating a string array having n items "Constant":

常量"& INDEX(XFD:XFD,1):INDEX(XFD:XFD,3)

有3个.

用于公式

= INDEX(常量"& INDEX(XFD:XFD,1):INDEX(XFD:XFD,3),0)

评估公式表明它有效:

此处使用 XFD 列,因为在大多数情况下,该列为空,并且此解决方案需要一个保证为空的列.

Here column XFD is used because in most cases this column will be empty and a column which is guaranteed to be empty is needed for this solution.

如果使用

常量"& T(ROW($ A $ 1:INDEX($ A:$ A,3)))

= INDEX("Constant"& T(ROW($ A $ 1:INDEX($ A:$ A,3))),0)

一个空列的需求消失了.函数 ROW 返回数字,但如果 T 的参数不是文本,则返回空字符串.因此,将为每个1:3(n)串联空字符串.

the need of an empty column disapears. The function ROW returns numbers but the T returns an empty string if it's parameter is not text. So empty strings will be concatenated for each 1:3 (n).

感谢@MacroMarc的提示.

Thanks to @MacroMarc for the hint.

这篇关于Excel:使用n倍常数创建数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆