views:

88

answers:

2

I need to be able to convert cells from one format to another according to the following rules:

Property Description    --enter as--    Folio Identifier
----------------------------------------------------------
Lot 23 DP789678                         23/789678
Lot 7 Section 12 DP6789                 7/12/6789
Lot 1 SP 45676                          1/SP45676
Common Property Title SP45676           CP/SP45676
Volume 7456 Folio 56                    7456-56
Auto-Consol 5674-78                     5674-78
Water Access Licence No. 123            WAL123

So the thing on the left has to be changed to the item on the right. For example, if I have any cells that look like Lot 23 DP789678, they must be converted to Lot 23 DP789678. How do I write a formula that will do this for all the above cases?

A: 

You can use the MATCH and INDEX functions. Suppose Property Description and Folio Identifier are in columns A1:A7 and B1:B7 respectively, and the string you want to replace is in A12, then let B12 be:

=INDEX(B1:B7,MATCH(A12,A1:A7,0))

E.g.

                A                          B
1   Lot 23 DP789678                23/789678
2   Lot 7 Section 12 DP6789        07/12/89
3   Lot 1 SP 45676                 1/SP45676
4   Common Property Title SP45676  CP/SP45676
5   Volume 7456 Folio 56           7456-56
6   Auto-Consol 5674-78            5674-78
7   Water Access Licence No. 123   WAL123
8    
9    
10   
11   
12  Lot 23 DP789678                23/789678
13  Common Property Title SP45676  CP/SP45676
14  Water Access Licence No. 123   WAL123
15  Water Access Licence No. 123   WAL123
Jacob
I think you've misunderstood. They are examples of formats, not hard-coded examples. So If I get Lot 25 DP321 I would want 25/321.
jonty
But what is your criteria for converting the text? Do you only choose numbers or is it space-delimited? Could you give us more information regarding the format?
Jacob
+1  A: 

I've got a formula for you. The only problem is that I couldn't fit it into one cell. It is just too big and Excel complains about it. So it has to be done in 2 steps. A1 contains your original text. D1 will contain intermediate result (you can hide this column if you want) E1 will contain the final result.

Formula for D1:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, "Lot ", ""), "Section ", ""), "SP ", "SP"), "Common Property Title", "CP"), "Volume ", ""), "Auto-Consol ", ""), "Water Access Licence No. ", "WAL"), " Folio ","-")

Formula for E1:

=SUBSTITUTE(D1, " ", "/")
DmitryK
Thanks. But there is a problem with this. Even when I changed E1 to =SUBSTITUTE(SUBSTITUTE(D1, "DP", "0")," ", "/")For input such as Lot 817 DP 1005981 I would get 817/0/1005981
jonty
And what is the correct result for this case?
DmitryK