Home > Software design >  Turn one_two to getOneTwo
Turn one_two to getOneTwo

Time:04-27

I have a bunch of variables in the form of one, two, three, four_five and I'd like to turn them to getOne, getTwo, getThree, getFourFive...

I wrote a formula that achieves what I want for the first three ones, but I can't achieve the CamelCase to variables with two words (or more) separated by an underscore.

So the formula I wrote is this:

=CONCAT("get";UPPER(LEFT(A1;1));RIGHT(A1;LEN(A1)-1))

How can this be expanded to achieve what I need? TIA

CodePudding user response:

Using SUBSTITUTE and PROPER:

="get"&SUBSTITUTE(PROPER(A1),"_","")

enter image description here

Since your version of Excel uses ; as the list separator:

="get"&SUBSTITUTE(PROPER(A1);"_";"")
  • Related