AONEDIM

=AONEDIM(Array)

Array
Required. Range to check if it is one dimensional or not.

Checks if an array is one dimensional and returns "H", "V", or an error message.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Checks if an array is one dimensional and returns "H", "V", or an error message.
Horizontal arrays (across columns) return "H", vertical arrays (down rows) return "V", and 2D arrays return a "One row/column" message.
Calls CELLCOUNT

Excel Formula:
=LAMBDA(Array,
      LET(Arr, Array,    RowCt, CELLCOUNT(Arr, 1),    ColCt, CELLCOUNT(Arr, 2),    Horiz?, ColCt>RowCt,
          ArrScan, AND(RowCt>1, ColCt>1),    ArrMSG, "One row/column",
          Result, IF(Horiz?, "H", "V"),    Return, IF(ArrScan, ArrMSG,  Result),
      Return)
  )
REVERSE Test.xlsx
ABCDEF
1AONEDIM
2Checks if an array is one dimensional (horizontal or vertical)
32D arrays return error message
41D arrays return "H" for horizontal {1,2,3} & "V" for vertical {1;2;3}
5Used in many other functions to ensure correct syntax
6
7Original DataResult
8HelloThere!One row/column
9My Name PatrickI am 27.
10
11Data array is 2D --> error message is returned
12=AONEDIM(B8:C9)
13
14
15
16Original DataResult
17HelloV
18There!
19My Name Patrick
20I am 27.
21
22Data array is 1D --> "V" is returned
23=AONEDIM(B17:B20)
24
25
26
27Original Data
28HelloThere!My Name PatrickI am 27.
29
30Result
31H
32
33Data array is 1D --> "H" is returned
34=AONEDIM(B28:E28)
35
AONEDIM
Cell Formulas
RangeFormula
E8E8=AONEDIM(B8:C9)
B12B12=FORMULATEXT(E8)
E17E17=AONEDIM(B17:B20)
B23B23=FORMULATEXT(E17)
B31B31=AONEDIM(B28:E28)
B34B34=FORMULATEXT(B31)
 
Upvote 0
AONEDIM has been updated. There is a new optional argument to treat single cells as horizontal arrays instead of vertical arrays. This will mainly be used in error checking LAMBDA arguments that only allow one dimensional arrays (or single cells). Before single cells always returned "V" for vertical. This was a problem for arguments requiring horizontal arrays (or single cells). For most applications, this argument will be omitted.

I found it was easier, shorter, and faster to add a little bit of code to this function than to add additional code in other functions.


AONEDIM checks if an array is one dimensional and returns "H", "V", or an error message.

Horizontal arrays (across columns) return "H", vertical arrays (down rows) return "V", and 2D arrays return a "One row/column" message.
Single cell behavior can be changed when checking if arrays are one dimensional using the optional Horizontal argument.
Calls CELLCOUNT.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =AONEDIM(Array☛ range to check if it is one dimensional or not, [Horizontal]☛ 1=treat single cells as horizontal; 0/❎=treat as vertical✅) ⁂[]= optional; ✅=default; ❎=omit

The syntax is slightly different: ARESIZE(Array,[Horizontal])

There is one additional argument: [Horizontal].
1. Inputting 0 or omitting it, makes the function act normally: a single cell returns "V" for vertical array.
2. Inputting 1 for it makes a single cell return "H" for horizontal array.
Array: Required. Range to check if it is one dimensional or not.
[Horizontal]: Optional. 1☛ treat single cells as horizontal; 0 or ignored☛ treat as vertical.

Excel Formula:
=LAMBDA(Array,[Horizontal],
      LET(Arr, Array,          Hor, Horizontal,
             RowCt, CELLCOUNT(Arr, 1),          ColCt, CELLCOUNT(Arr, 2),
             ArrScan, AND(RowCt>1, ColCt>1),          ArrMSG, "One row/column",
             HorScan, AND(Hor<>{1,0}),          HorMSG, "Horizontal=1,0",
             ERRORS, IFS(ArrScan, ArrMSG,  HorScan, HorMSG,  1, 0),
             Single?, AND(RowCt=1, ColCt=1),          H?, ColCt>RowCt,
             Result, IF(OR(AND(Single?, Hor=1), H?), "H",  "V"),
             Return, IF(ERRORS<>0, ERRORS,  Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEF
34Original DataResult
35Hello ThereV
36
37Data is a single cell --> "H" is returned
38Formula in cell E35☛ =AONEDIM(B35)
39
40
41
42Original DataResult
43Hello ThereH
44
45Data is a single cell --> "H" is returned
46Formula in cell E43☛ =AONEDIM(B43, 1)
47
AONEDIM
Cell Formulas
RangeFormula
E35E35=AONEDIM(B35)
B38,B46B38=AFORMULATEXT(E35)
E43E43=AONEDIM(B43, 1)
 
Quick update: I just realized the updated syntax is wrong.

It shows ARESIZE(Array,[Horizontal]). It should be AONEDIM(Array,[Horizontal]).

If a page admin can change this, that would be great. I can report it for incorrect syntax if need be.
 

Forum statistics

Threads
1,223,099
Messages
6,170,111
Members
452,302
Latest member
TaMere

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