问题
I have a data like below:
A:B:C:D
and I want to replace the C
with data (say, Z
) so that it may look like
A:B:Z:D
How can I do it?
回答1:
=SUBSTITUTE(A1,"C","Z")
Although I wasn't clear on whether you wanted G
or Z
, you mentioned G
but your example output shows Z
.
回答2:
If you have A:B:C:D in cell A1, then this works:
=CONCATENATE(MID(A1, 1, SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + SEARCH(":", A1)), "Z", MID(MID(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1), SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1, LEN(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) - SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1), SEARCH(":", MID(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1), SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1, LEN(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) - SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1)), LEN(MID(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1), SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1, LEN(MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) - SEARCH(":", MID(A1, SEARCH(":", A1) + 1, LEN(A1) - SEARCH(":", A1) + 1)) + 1))))
I know it's incredibly convoluted but it works.
EDIT: And to be clear, you'd replace "Z" with the data you want to add in.
来源:https://stackoverflow.com/questions/11517628/replacing-one-character-with-another-in-a-string