How to replace a character in excel in special circumstances -
So I have a 71563 x 3 dataset, which contains a list of chemical molecular formulas. An example of such a chemical formula is C40H56O4, where the letters represent a chemical and their multiplicity of numbers. Whatever I want to do, I replace all the characters with the letter 'O' with a small case 'o', but only if 'o' is between two numbers, or else there is a character before it . Therefore for example: -
C57H85N 9O9 will become C57H85N 9o9 , but the C6H13 will be equal to NO2 < / P> Thank you Sorry, I should first have said that there are such instances in which the first one is the letter 'O', but after that there is nothing. For example: - C8H16O, which should be C8H16o OK, so my solution is probably not the highest Compact though it works using formulas, you have to adjust for three columns, but how will it work here if all your data were alone in column A? Add this formula to column B. It ignores the OO chief by starting on the second letter in the cell, it gives the condition of the first o in the cell. Add this to column B which will give you three Letter string The first number that gives it in column C . Column D check if column C is integer. The column is in place of E. Note that it assumes that only one o copy will be molecule. I will try to update it to check for many o. EDIT: I have given it below in a single cell formula. However, to explain the above steps.
= FIND ("O", A1, 2)
= Middle (A1, B1 - 1,3)
= LEFT (C1, 1)
= IF (IFERROR (INT (D1), FALSE), A1, FALSE)
= IF (E1 <> wrong, again (A1, B1-1,3, LEFT (C1, 1) and "O" and right (C 1, 1)), A1)
= IF (IFERROR (INT (MID (A1, FIND ("O", A1,2) - 1, 1)), FALSE; & gt; FALSE, REPLACE (A 1, FIND ("O", A1,2), 1, "O"), A1)
Comments
Post a Comment