简体   繁体   中英

Substituting excel cell with a condition

I have an excel column A which contains some data. If the cell starts with </li> then the every </li> should be replaced by <u> . The formula should not replace </li> appearing any where except the first one.

Try this formula, (obv sub A1 with the cell where the text to replace are):

=IF(LEFT(A1;5)="</li>";SUBSTITUTE(A1;"</li>";"<u>");A1)

这是一个样本

But if you want to replace only the first instance in the cell who start with , you should do:

=IF(LEFT(A1;5)="</li>";SUBSTITUTE(A1;"</li>";"<u>";1);A1)

We use the "instance_num" parameter of the substitute function, to tell her to replace only the first instance, here what happens:

第二样本

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM