Sep 12 2023 02:00 AM
I need to extract the each letters of a word / words in to each separate cells.
(example attached)
or
I need to count the occurrence in of a particular letters in a table.
(example attached)
the purpose is to know the number of each letter so that I can order printing quantity accordingly.
Sep 12 2023 02:13 AM
Solution@Vimal_Gaur Provided you are using Excel365 or 2021, have a look at the attached file.
The green shaded areas is where I entered my formulas.
Sep 12 2023 02:32 AM
Sep 12 2023 02:47 AM
@Vimal_Gaur I merely replicated what was in your file. But WITH formulas. Did you note the formula in C11 and below? That's splitting each text string in B into separate cells. If that's not what you wanted, I misunderstood.
Sep 12 2023 05:26 AM
simple
A1 contains "States"
B1 "S", C1 "t", D1 "a", E1 "t", F1 "e", G1 "s"
or
A1 contains "States"
B1 "S", C1 2
B2 "t", C2 2
B3 "a", C3 2
B4 "e", C3 2
purpose - I want gift Table Clock with personal name written on clock's side panel. I have to give the quantity of each letter to the printing guy. So he will print exact quantity with sequence so that it will be easy for my to paste on the panel.
Sep 12 2023 05:40 AM
I believe that exactly what I demonstrated in my file. If not, you have lost me, sorry.
Sep 12 2023 05:50 AM
@Riny_van_Eekelen I may have lost as per you, so count in attached file IF YOU CAN
Sep 12 2023 06:02 AM
@Vimal_Gaur Here you go. One solution with new excel and one for old excel.
Sep 12 2023 07:05 AM
=DROP(IFERROR(REDUCE("",SEQUENCE(ROWS(A2:A6)),LAMBDA(x,y,VSTACK(x,TRANSPOSE(MID(INDEX(A2:A6,y),SEQUENCE(LEN(INDEX(A2:A6,y))),1))))),""),1)
An alternative could be this formula. It uses @Riny_van_Eekelen 's formula along with LAMBDA and REDUCE to spill the results.
Sep 12 2023 10:35 PM
Sep 12 2023 10:36 PM
Sep 13 2023 01:07 AM
LAMBDA is only available in Office 365 and Excel for the web. The LAMBDA formula is an alternative. The other functions return the intended result as well in my sheet.
Sep 13 2023 02:36 PM
The discussion has moved on somewhat since I read it. What I did was to explore a more 'packaged' solution, unfortunately using 365 techniques to the full. I went as far as a single formula that uses Lambda function but is not itself a Lambda function.
= LET(
characters, Explodeλ(name),
letterCount, CountByLetterλ(characters),
letterCount
)
The Lambda functions are
Explodeλ(list)
"Separates strings into single characters"
= LET(
n, MAX(LEN(list)),
MID(list, SEQUENCE(1, n), 1)
)
and
CountByLetterλ(chars)
"Counts occurrences of each letter of the alphabet within an array of characters"
= LET(
alphabet, CHAR(SEQUENCE(26, 1, 65)),
count, MAP(alphabet,
LAMBDA(chr,
SUM(SIGN(chars = chr))
)),
HSTACK(alphabet, count)
)
Because I had converted the list of names to an Excel table, all I had to do was copy/paste the new list of names to the table to have it resize.
Sep 13 2023 07:08 PM
Sep 14 2023 12:08 AM
Yes, it is possible to deconstruct the Lambda functions, though it is not something I would usually do.
Helper ranges are used in place of LET local named variables and the code within each Lambda function is placed directly within the formula cell. References passed by name are replaced by hard-wired references. One advantage of using helper ranges is that some, otherwise very good, Excel built-in functions, like COUNTIFS, only accept range references and fail with arrays.
The result of this process will be very close to one of the solutions you already have. To roll the solution back to pre-dynamic-array days one would have to use relative referencing to pick out the elements of the solution array or resort to CSE. Some would see such a process as achieving 'simplicity'; others see it as creating an error-prone mess; it all depends on one's view point.
Sep 14 2023 01:15 AM
Sep 14 2023 02:17 AM
I expect so but, if your are not going to use the Excel formula language, why use a spreadsheet?
I do not understand where your requirements are coming from. Who says you need one process?
In the attached, I have used a hidden helper sheet. At casual inspection, one wouldn't even know it existed.
I have also solved the problem with PowerQuery a lot easier than it would be with VBA.
Sep 14 2023 02:50 AM
Sep 14 2023 03:03 AM
If you click on the output table you should see a Query ribbon tab and, from there, be able to open the query for editing.
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Split Column by Position" = Table.SplitColumn(Source, "Name", Splitter.SplitTextByRepeatedLengths(1), {"Name.1", "Name.2", "Name.3", "Name.4", "Name.5", "Name.6", "Name.7", "Name.8", "Name.9", "Name.10", "Name.11"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Split Column by Position", {"S No"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"S No", "Attribute"}),
#"Grouped Rows" = Table.Group(#"Removed Columns", {"Value"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Sorted Rows1" = Table.Sort(#"Grouped Rows",{{"Value", Order.Ascending}}),
#"Filtered Rows" = Table.SelectRows(#"Sorted Rows1", each [Value] <> " " and [Value] <> ""),
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Value", "Letter"}})
in
#"Renamed Columns"
@Riny_van_Eekelen has more experience in that area than I do.
Sep 14 2023 03:16 AM
I have looked back over the PowerQuery M code and have simplified a couple of steps
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Columns1" = Table.RemoveColumns(Source,{"S No"}),
#"Split Column by Position" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns1", {{"Name", Splitter.SplitTextByRepeatedLengths(1), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Name"),
#"Renamed Columns1" = Table.RenameColumns(#"Split Column by Position",{{"Name", "Letter"}}),
#"Grouped Rows" = Table.Group(#"Renamed Columns1", {"Letter"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each [Letter] <> " " and [Letter] <> ""),
#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Letter", Order.Ascending}})
in
#"Sorted Rows"
but, as I suggested, I claim no special expertise in this area.
Sep 12 2023 02:13 AM
Solution@Vimal_Gaur Provided you are using Excel365 or 2021, have a look at the attached file.
The green shaded areas is where I entered my formulas.