How to Extract Unique Ledger Account Names from Line-Break Text in Excel
Question details
The user needs to extract distinct ledger account names from a cell range where each cell contains multiple lines separated by carriage returns, while omitting the final narration line.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Cleaning and processing exported accounting data by extracting specific account names dynamically without keeping the transaction narrations.
- Observed behavior
- Exported data groups multiple ledger entries into single cells with line breaks and a trailing narration line, requiring a dynamic formula to split, filter, and extract the unique names into a list.
Ensure you are using a modern spreadsheet version (like Microsoft 365 or the latest WPS Office) that supports dynamic array functions such as LET, UNIQUE, TEXTSPLIT, and VSTACK.
Use LET, UNIQUE, and TEXTSPLIT Functions
Combine all text, split by carriage returns, and filter out the unwanted narration lines dynamically.
Click on the cell where you want the extracted list of unique ledger account names to begin spilling.
Enter the following formula into the formula bar: =LET(v,UNIQUE(TEXTSPLIT(TEXTJOIN(CHAR(10),TRUE,VSTACK(B10:B13)),,CHAR(10))),FILTER(v,ISERROR(SEARCH("Bill No",v))))
Change B10:B13 to match your actual data range, and update "Bill No" to the specific text that identifies the final narration line in your accounting software export.
Extract Using REDUCE and LAMBDA Functions
Iterate through each cell to drop the last line and stack the unique values.
Extract Using TEXTBEFORE and TEXTAFTER
Remove the final narration line first, then split the remaining lines into a single column.
Process Complex Accounting Data in WPS Office
WPS Spreadsheet provides powerful dynamic array functions and text manipulation tools to handle multi-line cell data effortlessly. It is an excellent free alternative for complex data cleaning tasks.
- 1. Open your data file: Launch WPS Spreadsheet and open the exported accounting ledger.
- 2. Apply dynamic formulas: Use modern array functions like UNIQUE and TEXTSPLIT directly in the formula bar to manipulate your data.
- 3. Analyze and save: Review the extracted unique accounts and save your workbook in the standard .xlsx format to ensure compatibility.

Frequently Asked Questions
What does CHAR(10) do in these formulas?
CHAR(10) represents a line break (carriage return) in Excel. It is used as the delimiter to tell functions like TEXTSPLIT and TEXTJOIN where one line ends and another begins within the same cell.
Why am I getting a #CALC! error with my formula?
The #CALC! error often occurs if the FILTER function doesn't find any results that meet the criteria, or if you are using an older version of the spreadsheet software that does not support dynamic array formulas.
How can I extract unique values if I don't have Office 365?
If you don't have access to modern functions like TEXTSPLIT, you can use Power Query to split the column by delimiter (choosing line feed), unpivot or append the data into a single column, and then remove duplicates.
Can I filter out multiple different narration markers?
Yes. You can expand the FILTER criteria by using the multiplication operator (*) for 'AND' logic or the addition operator (+) for 'OR' logic within the ISERROR and SEARCH functions.




