Advertisement
nicolaslagios

Apostrophe Solution for excel PROPER formula

Dec 8th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | Source Code | 0 0
  1. Let's say the cell you want to correct is A2.
  2. Use the following formula:
  3. =ARRAYFORMULA(IF(A2="",,REGEXREPLACE(PROPER(A2), "'([A-Z])", "'$1")))
  4.  
  5. If for some reason it is not working, use the following that it works 100% and corrects the 'S letter:
  6. =ARRAYFORMULA(IF('01. Conv - Build'!A9="",,REGEXREPLACE(PROPER('01. Conv - Build'!A9), "'S", "'s")))
  7.  
  8. Last but not least, here is a hardcoded formula for the entire alphabet:
  9. =REGEXREPLACE(REGEXREPLACE(REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( REGEXREPLACE( PROPER(A2), "'A","'a"), "'B","'b"), "'C","'c"), "'D","'d"), "'E","'e"), "'F","'f"), "'G","'g"), "'H","'h"), "'I","'i"), "'J","'j"), "'K","'k"), "'L","'l"), "'M","'m"), "'N","'n"), "'O","'o"), "'P","'p"), "'Q","'q"), "'R","'r"), "'S","'s"), "'T","'t"), "'U","'u"), "'V","'v"), "'W","'w"), "'X","'x"),"'Y","'y"),"'Z","'z")
  10.  
  11.  
  12. Before:
  13. After:
  14.  
  15. Explanation:
  16. PROPER(): Converts text to proper case, where the first letter of each word is capitalized.
  17. REGEXREPLACE():
  18. The pattern "'([A-Z])" matches an apostrophe (') followed by any uppercase letter ([A-Z]).
  19. The replacement "'$1" keeps the apostrophe and replaces the uppercase letter with itself (from the captured group).
  20. ARRAYFORMULA(): Ensures the formula applies across the entire range of the column, starting at A9.
  21. This will ensure all instances of 'A, 'B, 'C, etc., are converted to lowercase following the apostrophe, such as 'a, 'b, 'c.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement