I have a long list of accounts exported from my accounting software, which for reasons known to itself (it doesn't talk to me) lists the sub accounts in one long row with its parents, grandparents and all forefathers in one row. For example
6 · EXPENSES ACCOUNTS:67 · Tax on profit & loss:673 · Foreign income taxes:6732 · Taxes incurred by perm estabs:67322 · Prior years
This is just one account name. The government here has imposed this new accounting plan or chart of accounts on us, and I need to parse this depending on the level of the account number.
The dot, btw, is not a full stop, but CHAR(183), and the entire column is formatted as text.
What I need to do is to test if there is a number ending two characters after the last dot, work out how long it is and extract it into one column (67322), and the name following it (Prior years) into the next column. If there is no five digit number in that cell, I need to work backwards until I find a four digit number, and extract the number and the name that stops before the colon. If there is no four digit number, then I need to work backwards until I find a three digit number and do the same. Finally, if there is no three digit number, I need to find a two digit number which will always exist.
This is far too complicated for my feeble brain, so any help would be gratefully received. It has to be formula driven and not a macro if possible.
Many thanks
Riaz
6 · EXPENSES ACCOUNTS:67 · Tax on profit & loss:673 · Foreign income taxes:6732 · Taxes incurred by perm estabs:67322 · Prior years
This is just one account name. The government here has imposed this new accounting plan or chart of accounts on us, and I need to parse this depending on the level of the account number.
The dot, btw, is not a full stop, but CHAR(183), and the entire column is formatted as text.
What I need to do is to test if there is a number ending two characters after the last dot, work out how long it is and extract it into one column (67322), and the name following it (Prior years) into the next column. If there is no five digit number in that cell, I need to work backwards until I find a four digit number, and extract the number and the name that stops before the colon. If there is no four digit number, then I need to work backwards until I find a three digit number and do the same. Finally, if there is no three digit number, I need to find a two digit number which will always exist.
This is far too complicated for my feeble brain, so any help would be gratefully received. It has to be formula driven and not a macro if possible.
Many thanks
Riaz