Excel replace underscore with next character in uppercase and remove underscore [duplicate] - excel-formula

This question already has answers here:
Camel case converter in an excel
(5 answers)
Closed 9 days ago.
I have some strings like avg_face_count and I need to convert them in avgFaceCount in Excel
Basically I need to find every underscore in the string, remove it and replace the next underscore character in uppercase
I tried https://superuser.com/questions/996712/excel-findreplace-lowercase-after-a-certain-character
but it only work for one underscore
thanks

=SUBSTITUTE(PROPER(SUBSTITUTE(A20,"_"," "))," ","")
It first replaces _ for a space character. Then creates Caps for the first character after the space and finally removes the spaces.
If you truly only need the character after _ to be in caps, then use this Office 365 solution:
=LET(cell, A2,
a, SEQUENCE(LEN(cell)),
SUBSTITUTE(
REDUCE( A20, a,
LAMBDA( b, c,
IF(MID(b,c,1)="_",
LEFT(b,c-1)&UPPER(MID(b,c,2))&RIGHT(b,MAX(a)-c-1),
b))),"_",""))

Related

Replace english characters to malayalam characters in excel

I want to replace English characters to Malayalam language characters as given criterio in excel
a=എ
b=ബി
C=സി
D=ഡി
E=ഇ
F=എഫ്
G=ജി
H=എച്ച്
I=ഐ
J=ജെ
K=കെ
L=എല്‍
N=എന്‍
M=എം
O=ഒ
P=പി
Q=ക്യു
R=ആര്‍
S=എസ്
T=ടി
U=യു
V=വി
W=ഡബ്ല്യു
X=എക്സ്
Y=വൈ
Z=ഇസെഡ്
For eg in column A "ABC" in Column B it has to appear as "എബിസി"
If you have O365
Set up a table with your equivalences (I NAME'd it tblLng)
Then, you can use this formula in B1:
=TEXTJOIN("",,VLOOKUP(MID(A1, SEQUENCE(LEN(A1)),1),tblLng,2,FALSE))
If you do not have the SEQUENCE function I can provide a substitute.
If you do not have the TEXTJOIN function, look into using helper columns and or VBA.
Edit
As now noted in the comments, the OP wants to replace also digits, and wild card characters.
Digits must be entered as text and not numbers, by either pre-pending the digit with a single quote; or pre-formatting the column as text.
wild card characters (asterisk, tilde, question mark), must be prepended with a tilde in order to search for the actual character.
The formula can be changed for wild-card characters:
MID portion:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(MID(A1, SEQUENCE(LEN(A1)),1),"~","~~"),"?","~?"),"*","~*")`
-entire formula:
=TEXTJOIN("",,VLOOKUP(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(MID(A1, SEQUENCE(LEN(A1)),1),"~","~~"),"?","~?"),"*","~*"),tblLng,2,FALSE))
It might not be elegant, but you can add something like this in B1 cell.
=SUBSTITUTE(SUBSTITUTE(A1;"A";"എ");"B";"ബി")
It reacts like the REPLACE function but will replace any instance of A or B in this case.
You can extent the function nesting more substitute calls.

How to extract a string from a cell from right to left using a specific character that occurs more than once?

Normally I would just use the RIGHT function in excel to split it by finding a specific character such as / and outputting the string that I want.
However, I am finding trouble extracting THISSTRING.txt from d/aaa/THISSTRING.txt. With only one instance of / I would just use a function such as =RIGHT(B17,LEN(B17) - FIND("/",B17))
Here's one way to get the rightmost:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",99)),99))
Objective: To return the rightmost sub-string from a target string after the last occurrence of a character which appears several times within the target string.
This formula:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",99)),99))
Provides the correct result under the following conditions:
The sub-string to retrieve does not have more than 99 characters.
The sub-string to retrieve does not contain more than one space character together.
Example: To retrieve a sub-string which is 123 characters long and contains the following characters 1 ABC XXX 123 XYZ.
Point 1 is easily solved by working with the length of the string instead of a fixed number:
=TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",LEN(A1))), LEN(A1)))
However point 2 can't be overcome with the referred formula.
Proposed solution: The following formula returns the correct result regardless of the conditions mentioned above:
=RIGHT(A1, LEN(A1) - FIND( CHAR(12),
SUBSTITUTE(A1, "/", CHAR(12), LEN(A1) - LEN( SUBSTITUTE(A1, "/", "" )))))
Note: I used non-printable character 12 which is very unlikely to be found in excel, change as required.
Here's another way.....
=REPLACE(B17,1,LOOKUP(2^15,FIND("/",B17,ROW(INDIRECT("1:"&LEN(B17))))),"")
FIND generates an array of values, indicating the first position of a "/" in B17, but with the start point incrementing by 1 each time, which means that the last numeric value in that array is the positon of the last "/".
LOOKUP extracts that value from the array and we can use it in REPLACE function to replace all characters before and at that position with nothing, just leaving you with all characters after the last "/"
You'll get an error if there is no "/" in B17

Find the number of same consecutive letters in a cell

I have a cell that contains:
DA - 7200A blankblankblank Dalton Karaoke box
Weight blankblank 10.2kg
Now I've been trying to find a way to substitute all those blank into ": " but got no result. Because the number of blanks in each line is different so I was thinking of how to find the number of blank standing next to each other and then substitute them with ": ".
That's what I thought but I couldn't write a formula for this.
You would use the substitute function to replace the first double blank with colon-blank :, then use the trim function to remove leading spaces, trailing spaces, and collapse multiple spaces to single.

Excel formula to delete a character from a string then replace another character with the same character that was deleted

I have a number of coordinates and wish to remove a "." separator, then replace a "," decimal with the standard UK format "." character.
e.g. 9.811.365,054 needs to be 9811365.054
I initially used a nested substitute formula but this also removed the "." leaving only numbers i.e. 9811365054
In VBE in the Immediate Window ctrl+g try
? replace(replace("9.811.365,054",".",""),",",".")
9811365.054
So pretty much you just nest two functions; first you replace all the dots with "" (nothing) and then replace the comma with a dot.
and an equivalent formula would be =SUBSTITUTE(SUBSTITUTE(A1,".",""),",",".") assuming A1 is 9.811.365,054

What is the significance of the question mark in Excel?

If I type in this formula:
=vlookup(A1,LetterTable,2,False)
With A1 set to "?" (without the quotes), and LetterTable contains this:
a a
b b
c c
... ...
- -
+ +
? ?
! !
It always gives me "a" (no quotes). Why is this?
Also, if I copy that into an array in vba and loop through it, comparing it to the spreadsheet value, it won't find it either.
See http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx:
If range_lookup is FALSE and lookup_value is text, then you can use the wildcard characters, question mark (?) and asterisk (*), in lookup_value. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the character.

Resources