How can I combine these two formulas into one

Bassie

Board Regular
Joined
Jan 13, 2022
Messages
66
Office Version
  1. 2019
Platform
  1. Windows
Hi,

So I basically wanna do two different things in the same formula. I got a working formula for both but I don't know how to combine them. I have a column full of sentences and what I want to do is to uppercase the first letter of the sentence and remove a . at the end of the sentence (if there is one).

Uppercasing only the first letter of a sentence:
=UPPER(LEFT(E19,1))&RIGHT(E19,LEN(E19)-1)

Removing the . after a sentence (if there is one)
=IF(RIGHT(E19,1)=".",LEFT(E19, LEN(E19) - 1),E19)

Is there a way to combine them? I am not a huge fan of helper columns as I would like my worksheets to look clean.

Thanks a lot in advance!
 
Borrowing from JvdV's idea how about
Excel Formula:
=REPLACE(REPLACE(E19,1,1,UPPER(LEFT(E19))),LEN(E19),1,SWITCH(RIGHT(E19),".","",",","",";","",RIGHT(E19)))
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Another option if you have Textbefore
Excel Formula:
=REPLACE(TEXTBEFORE(E19,{".",";",","},-1,,,E19),1,1,UPPER(LEFT(E19)))
 
Upvote 0
Another option if you have Textbefore
Excel Formula:
=REPLACE(TEXTBEFORE(E19,{".",";",","},-1,,,E19),1,1,UPPER(LEFT(E19)))

@Fluff if that answer is based on the fact that these characters only would occur at the end of a string (if they appear) I'd suggest TEXTSPLIT() instead which won't error out if neither of them is present. I did see you used the last parameter 'if not found' though =).

Excel Formula:
=REPLACE(TEXTSPLIT(E19,{".",",",";"},,1),1,1,UPPER(LEFT(E19)))

Btw, nice technique with REPLACE().
 
Upvote 0
Another option
Excel Formula:
=REPLACE(TEXTBEFORE(E19,{".",";",","},,,1),1,1,UPPER(LEFT(E19)))
It appears that the "match end" argument doesn't work if you use a -ve as the instance number
 
Upvote 0
It blows my mind what you two can do in so little time. I dont have the TEXTBEFORE function but

Excel Formula:
=REPLACE(REPLACE(E19,1,1,UPPER(LEFT(E19))),LEN(E19),1,SWITCH(RIGHT(E19),".","",",","",";","",RIGHT(E19)))

Works perfectly for my usecase.

Many thanks again!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top