ATOCHARS

ATOCHARS(Array,Remove_Nonprinting)
Array
Required. Array to return individual characters.
Remove_Nonprinting
Optional. 1☛ remove non-printing characters listed in CLEAN; 0 or ignored☛ don't remove

ATOCHARS returns an array of individual characters from a one dimensional array of text strings with an option to remove non-printing characters.

schardt679

Board Regular
Joined
Mar 27, 2021
Messages
58
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
ATOCHARS returns an array of individual characters from a one dimensional array of text strings with an option to remove non-printing characters.
Horizontal ranges spill down rows and vertical ranges spill across columns. Thanks to RicoS and their TEXTTOARRAY function for the inspiration. Calls AONEDIM & ATRIM.

Excel Formula:
=LAMBDA(Array,Remove_Nonprinting,
      LET(Arr, Array,
          RemNon?, Remove_Nonprinting,
          A1D?, AONEDIM(Arr),
          AScan, AND(A1D?<>{"H","V"}),
          Horiz?, A1D?="H",
          NonScan, AND(RemNon?<>{1,0}),
          NonMSG, "Nonprinting=1,0",
          ERRORS, IFS(AScan, A1D?,  NonScan, NonMSG,  1, 0),
          ArrTrim, IF(RemNon?=1, ATRIM(Arr,), Arr),
          Lengths, IFERROR(LEN(ArrTrim), 1),
          MaxLen, MAX(Lengths, 1),
          Start, SEQUENCE(IF(Horiz?, MaxLen, 1),  IF(Horiz?, 1, MaxLen)),
          Result, IF(Start>Lengths, "", MID(ArrTrim, Start, 1)),
          Return, IF(ERRORS<>0, ERRORS, Result),
          Return
      )
 )
LAMBDA Examples.xlsx
ABCDEFGHIJKLMNOP
1ATOCHARS
2
3TextResult
4 Hello Hello
5There!There!
6
7#N/A#N/A
8I am 27.I am 27.
9
10Data is a vertical array
11Result spills horizontally
12Nonprinting characters aren't removed
13=ATOCHARS(B4:B8,)
14
15
16
17TextResult
18 Hello Hello
19There!There!
20
21#N/A#N/A
22I am 27.I am 27.
23
24Data is a vertical array
25Result spills horizontally
26Nonprinting characters are removed
27=ATOCHARS(B18:B22, 1)
28
29
30
31Text Hello There!#N/AI am 27.
32
33Result T#N/AI
34Hh
35eea
36lrm
37le
38o
39 !
40
41
42 2
437
44.
45
46Data is a horizontal array
47Result spills vertically
48Nonprinting characters aren't removed
49=ATOCHARS(C31:G31,)
50
ATOCHARS
Cell Formulas
RangeFormula
D4:O8D4=ATOCHARS(B4:B8,)
B7,F31,B21B7=NA()
B13,B27B13=FORMULATEXT(D4)
D18:K22D18=ATOCHARS(B18:B22, 1)
C33:G44C33=ATOCHARS(C31:G31,)
B49B49=FORMULATEXT(C33)
Dynamic array formulas.
 
Upvote 0
ATOCHARS has been updated. Since the function calls ATRIM (removes extra occurrences of a specified delimiter and nonprinting characters listed in CLEAN), an optional Delimiter argument was added. By default, it is a space.

ATOCHARS returns an array of individual characters from a one dimensional array of text strings with an option to remove extra occurrences of a specified delimiter and non-printing characters.

Thanks to RicoS's TEXTTOARRAY function for the inspiration.
Horizontal ranges spill down rows and vertical ranges spill across columns.
Calls AONEDIM, IFBLANK, & ATRIM.
Other functions on minisheet: AFORMULATEXT.

Screen Tip/ Comment: =ATOCHARS(Array☛ range to return individual characters, [Clean_Data]☛ 1=remove extra delimiters and non-printing characters listed in CLEAN; 0/❎=don't✅, [Delimiter]☛ separator; ❎=" "✅) ⁂[]= optional; ✅=default; ❎=omit

The syntax is slightly different: ATOCHARS(Array,[Clean_Data],[Delimiter])

Array: Required. Array to return individual characters.
[Remove_Nonprinting] is now [Clean_Data]: Optional. 1☛ remove extra delimiters and non-printing characters listed in CLEAN; 0 or ignored☛ don't remove
[Delimiter]: Optional. Value separator(s); ignored☛ space. Can be multiple separators but the row/ column count must match array.

If {Clean_Data] is omitted [Delimiter] is irrelevant

Excel Formula:
=LAMBDA(Array,[Clean_Data],[Delimiter],
      LET(Arr, Array,          Clean?, IFERROR(--(Clean_Data), 2),          Del, IFBLANK(Delimiter, " "),
             A1D?, AONEDIM(Arr),          AScan, AND(A1D?<>{"H","V"}),          H?, A1D?="H",
             CleanScan, AND(Clean?<>{1,0}),          CleanMSG, "Clean_Data=1,0",
             ERRORS, IFS(AScan, A1D?,  CleanScan, CleanMSG,  1, 0),
             Trim?, IF(Clean?, ATRIM(Arr, Del),  Arr),          Lengths, IFERROR(LEN(Trim?), 1),
             MaxLen, MAX(Lengths, 1),          Start, SEQUENCE(IF(H?, MaxLen, 1),  IF(H?, 1, MaxLen)),
             Result, IF(Start>Lengths, "",  MID(Trim?, Start, 1)),          Return, IF(ERRORS<>0, ERRORS, Result),
             Return
      )
  )
LAMBDA Examples.xlsx
ABCDEFGHIJKLMNOPQRS
54ATOCHARS
55
56TextClean_Data:1Result
5703/22///21Delimiter:/03/22/21
58#VALUE!#VALUE!
5903//22///2103/22/21
6003//23/21 03/23/21
61
6203/23/2103/23/21
6303/24/2144279
64
65Data is a vertical array --> result spills horizontally
66Nonprinting characters and extra delimiters are removed
67Delimiter is slash
68Formula in cell G57☛ =ATOCHARS(B57:B63, E56, E57)
69
70
71
72TextClean_Data:1Result
731, , , 2, 3, , 4Delimiter:, 1, 2, 3, 4
74A;;B;C;;;D;A;B;C;D
75A1|A2|||B||C|A1|A2|B|C
76D||E|||F||||G||D||E|||F||G
77
78Data is a vertical array --> result spills horizontally
79Nonprinting characters and extra delimiters are removed
80There are multiple delimiters.
81Formula in cell G73☛ =ATOCHARS(B73:B76, E72, E73:E76)
82
ATOCHARS
Cell Formulas
RangeFormula
G57:O63G57=ATOCHARS(B57:B63, E56, E57)
B58B58=1+"A"
B68B68=AFORMULATEXT(G57)
G73:Q76G73=ATOCHARS(B73:B76, E72, E73:E76)
B81B81=AFORMULATEXT(G73)
Dynamic array formulas.
 

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