Forum Discussion

tony finch's avatar
tony finch
Copper Contributor
Nov 13, 2017

extracting text after the last : in a text field

I have a series of account number sin excel like

030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Superannuation
030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Vehicle Allowance
030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Leave adjustment - annual & LSL
030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Fringe Benefits Tax
030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Payroll tax

030.40 OVERHEADS / EXPENSES:SELLING / MARKETING OVERHEADS:EMPLOYEE EXPENSES:Salary charge - Bill Adamson

I need to extract the text to the right of the LAST : for each row

The complication is that there is a variable number of colons, and their position varies.

I use Len to find the length of the text, find to locate the position of the first : then use right to extract all the text after the :

I then value copy the result back onto the source text, and repeat until an error (because there is no :)

How do I write VBA to repeat this until the error and then move down to the next row and repeat again?