ACONSTANT

=ACONSTANT(Value,nRows,nCols)

Value
Optional. Value to repeat; ignored☛ empty string
nRows
Optional. Number of times to repeat value down rows; ignored☛ 1
nCols
Optional. Number of times to repeat value across columns; ignored☛ 1

ACONSTANT returns an array of value(s) repeated over a specified number of rows and columns.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
ACONSTANT returns an array of value(s) repeated over a specified number of rows and columns.

Thanks to GeertD's CONSTANTARRAY function for the inspiration.
Single values repeat down rows & across columns. Horizontal values repeat down rows. Vertical values repeat across columns.
If nRows or nCols have more than 1 value, the max number is used.
Optional arguments require comma to work. Calls AONEDIM & CELLCOUNT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =ACONSTANT([Value]☛ value to repeat; ❎=""✅, [nRows]☛ number of rows to repeat value; ❎=1✅, [nCols]☛ number of columns to repeat value; ❎=1✅) ⁂[]=optional: use ","; ✅=default; ❎=omit

Excel Formula:
=LAMBDA(Value,nRows,nCols,
      LET(Val, Value,          nRow, MAX(N(IFERROR(nRows,))),          nCol, MAX(N(IFERROR(nCols,))),
             A1D?, AONEDIM(Val),          AScan, AND(A1D?<>{"H","V"}),
             NumScan, OR(nRow<0, nCol<0),          NumMSG, "nRows/nCols>=1",
             ERRORS, IFS(AScan, A1D?,  NumScan, NumMSG,  1, 0),
             RowCt, CELLCOUNT(Val, 1),          RowTot, IFS(RowCt>1, RowCt,  nRow=0, 1,  1, nRow),
             ColCt, CELLCOUNT(Val, 2),          ColTot, IFS(ColCt>1, ColCt,  nCol=0, 1,  1, nCol),
             RowSeq, SEQUENCE(RowTot,,, IF(RowCt>1, 1, 0)),          ColSeq, SEQUENCE(, ColTot,, IF(ColCt>1, 1, 0)),
             Result, INDEX(IF(Val="", "", Val), RowSeq, ColSeq),
             Return, IF(ERRORS<>0, ERRORS, Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJKL
1ACONSTANT
2
3ValuenRowsnColsResult
43.14333.143.143.14
53.143.143.14
63.143.143.14
7
8Value is a single cell
9Value is repeated down 3 rows and across 3 columns
10Formula in cell H4☛ =ACONSTANT(B4, D4, E4)
11
12
13
14ValuenRowsnColsResult
15A34AAAA
16BBBBB
17
18Value array is a vertical array
19Values are repeated across 4 columns
20Formula in cell H15☛ =ACONSTANT(B15:B16, D15, E15)
21
22
23
24ValuenRowsnColsResult
25Item 1, Item 2Item 3, Item 434Item 1, Item 2Item 3, Item 4
26Item 1, Item 2Item 3, Item 4
27Item 1, Item 2Item 3, Item 4
28
29
30Value array is a horizontal array
31Values are repeated down 3 rows
32Formula in cell H25☛ =ACONSTANT(B25:C25, D25, E25)
33
34
35
36ValuenRowsnColsResult
3707/08/21207/08/21
3807/08/21
39
40Value is a single cell
41Value is repeated 2 times down rows and once across columns
42Formula in cell H37☛ =ACONSTANT(B37, D37, E37)
43
44
45
46ValuenRowsnColsResult
4733 
48
49
50
51Value is single cell
52Value is repeated down 3 rows and across 3 columns
53Formula in cell H47☛ =ACONSTANT(B47, D47, E47)
54
55
56
57ValuenRowsnColsResult
58#N/A112#N/A#N/A
592#N/A#N/A
603#N/A#N/A
614#N/A#N/A
62Value is single cell
63Value is repeated down 4 rows and across 2 columns
64Formula in cell H58☛ =ACONSTANT(B58, D58:D61, E58:F58)
65
ACONSTANT
Cell Formulas
RangeFormula
H4:J6,H47:J49,H37:H38H4=ACONSTANT(B4, D4, E4)
B10,B64,B53B10=AFORMULATEXT(H4)
H15:K16H15=ACONSTANT(B15:B16, D15, E15)
B20,B42B20=AFORMULATEXT(H15)
H25:I27H25=ACONSTANT(B25:C25, D25, E25)
B32B32=AFORMULATEXT(H25)
H58:I61H58=ACONSTANT(B58, D58:D61, E58:F58)
Dynamic array formulas.
 
Upvote 0
ACONSTANT has been rewritten. It is shorter, takes advantage of the optional argument syntax, and values can now be repeated in a looped manner.

ACONSTANT returns an array of value(s) repeated over a specified number of rows and columns.

Thanks to GeertD's CONSTANTARRAY function for the inspiration.
If nRows or nCols have more than 1 value, the max number is used.
If nRows/ nCols are greater than Array RowCt / ColCt, it loops back the top/ left value of the Array.
If nRows/ nCols are less than Array RowCt / ColCt, it repeats up to that row/ column of the Array.
If skipping arguments, a comma is required. Calls IFBLANK & CELLCOUNT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =ACONSTANT([Value]☛ value to repeat; ❎=""✅, [nRows]☛ number of rows to repeat value; ❎=1✅, [nCols]☛ number of columns to repeat value; ❎=1✅) ⁂[]=optional; ✅=default; ❎=omit

The syntax is the same: ACONSTANT([Value],[nRows],[nCols])

The arguments are the same nut it now repeats the Value argument differently.
1. Single values still repeat across rows and columns.
2. If nRows or nCols is greater than the Value Array row or column count, the values are looped until that number is reached.
3. If nRows or nCols is less than the Value Array row or column count, the values are indexed to that row or column number.
[Value]: Optional. Value to repeat; ignored☛ empty string.
[nRows]: Optional. Number of times to repeat value down rows; ignored☛ 1.
[nCols]: Optional. Number of times to repeat value across columns; ignored☛ 1.

Excel Formula:
=LAMBDA([Value],[nRows],[nCols],
      LET(Val, IFBLANK(Value, ""),          nRow, IFERROR(--(nRows),),          nCol, IFERROR(--(nCols),),
             NumScan, OR(nRow<0, nCol<0),          NumMSG, "nRows/nCols>=1",
             RowCt, CELLCOUNT(Val, 1),          RowSeq, MOD(SEQUENCE(MAX(nRow, 1),, 0), RowCt)+1,
             ColCt, CELLCOUNT(Val, 2),          ColSeq, MOD(SEQUENCE(, MAX(nCol, 1), 0), ColCt)+1,
             Result, INDEX(Val, RowSeq, ColSeq),
             Return, IF(NumScan, NumMSG,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJKL
1ACONSTANT
2
3ValuenRowsnColsResult
43.14333.143.143.14
53.143.143.14
63.143.143.14
7
8Value is a single cell
9Value is repeated down 3 rows and across 3 columns
10Formula in cell H4☛ =ACONSTANT(B4, E4, F4)
11
12
13
14ValuenRowsnColsResult
15A34AAAA
16BBBBB
17AAAA
18Value array is a vertical array
19Value is repeated down 3 rows and across 4 columns
20Formula in cell H15☛ =ACONSTANT(B15:B16, E15, F15)
21
22
23
24ValuenRowsnColsResult
25Item 1, Item 2Item 3, Item 443Item 1, Item 2Item 3, Item 4Item 1, Item 2
26Item 1, Item 2Item 3, Item 4Item 1, Item 2
27Item 1, Item 2Item 3, Item 4Item 1, Item 2
28Item 1, Item 2Item 3, Item 4Item 1, Item 2
29
30Value array is a horizontal array
31Value is repeated down 4 rows and across 3 columns
32Formula in cell H25☛ =ACONSTANT(B25:C25, E25, F25)
33
34
35
36ValuenRowsnColsResult
37Item 1, Item 2Item 3, Item 433Item 1, Item 2Item 3, Item 4Item 1, Item 2
38Item 5, Item 6Item 7, Item 8Item 5, Item 6Item 7, Item 8Item 5, Item 6
39Item 1, Item 2Item 3, Item 4Item 1, Item 2
40
41
42Value array is a 2D array
43Value is repeated down 3 rows and across 3 columns
44Formula in cell H37☛ =ACONSTANT(B37:C38, E37, F37)
45
46
47
48
49
50
51ValuenRowsnColsResult
5208/08/212308/08/2108/08/2108/08/21
5308/09/2108/09/2108/09/2108/09/21
5408/10/21
55
56Value array is a vertical array
57Value is repeated down 2 rows and across 3 columns
58Formula in cell H52☛ =ACONSTANT(B52:B54, E52, F52)
59
60
61
62ValuenRowsnColsResult
6333 
64
65
66
67Value is single cell
68Value is repeated down 3 rows and across 3 columns
69Formula in cell H63☛ =ACONSTANT(B63:C64, E63, F63)
70
71
72
73ValuenRowsnColsResult
74#N/A11#N/A#N/A
7522#N/A#N/A
763#N/A#N/A
774#N/A#N/A
78Value is single cell
79Value is repeated down 4 rows and across 2 columns
80Formula in cell H74☛ =ACONSTANT(B74, E74:E77, TRANSPOSE(F74:F75))
81
ACONSTANT
Cell Formulas
RangeFormula
H4:J6H4=ACONSTANT(B4, E4, F4)
B10,B80,B69,B58B10=AFORMULATEXT(H4)
H15:K17H15=ACONSTANT(B15:B16, E15, F15)
B20B20=AFORMULATEXT(H15)
H25:J28H25=ACONSTANT(B25:C25, E25, F25)
B32,B44B32=AFORMULATEXT(H25)
H37:J39,H63:J65H37=ACONSTANT(B37:C38, E37, F37)
H52:J53H52=ACONSTANT(B52:B54, E52, F52)
H74:I77H74=ACONSTANT(B74, E74:E77, TRANSPOSE(F74:F75))
Dynamic array formulas.
 
Last edited:

Forum statistics

Threads
1,223,604
Messages
6,173,316
Members
452,510
Latest member
RCan29

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top