A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
The number of rows shouldn't be a problem. Excel can easily handle 18,700 rows. Since both alphabetical sorting and your numeric helper-column approach produced the same result, I would first suspect an issue with the structure of the imported data or the way Excel is interpreting the values.
The first thing to check is whether Excel is sorting the entire dataset as one range. Select the entire dataset, including all columns, then choose Data > Sort. Make sure My data has headers is checked if the first row contains headings. If Excel prompts you to expand the selection, choose Expand the selection. Also check for completely blank rows that might divide the report into separate data regions.
Another possibility is that the imported values contain invisible characters. For example, some cells might contain Invoice while others contain Invoice (a trailing space) or a nonbreaking space. These values look identical but are technically different. To clean the values, create a helper column using this formula:
=TRIM(CLEAN(SUBSTITUTE(X2,CHAR(160)," ")))
Replace X2 with the appropriate cell reference, fill the formula down, and then copy the results and use Paste Special > Values. Try sorting using this cleaned column.
You can also use the Filter feature (Data > Filter) on the original column. Examine the dropdown list to see whether Excel recognizes exactly three distinct entries: (Blanks), Invoice, and Payment. If additional entries appear that look identical to Invoice or Payment, the imported data contains inconsistent text values.
Finally, check whether the report contains merged cells or blank rows within the data. These can interfere with sorting and cause Excel to treat portions of the report as separate ranges.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin