12

I am trying to convert a field in an excel sheet (e.g. REC_LEN) to camel case. I am using this formula to do that

=LEFT(A1) & RIGHT(SUBSTITUTE(PROPER(A1),"_",""), LEN( SUBSTITUTE(A1,"_",""))-1) 

This is giving me results like RecLen. I want to convert my first letter to lowercase too (The expected output is recLen). Can somebody help me out with this? I am not too familiar with excel formulae. Not sure if this has been already asked before but any help is much appreciated.

Twisha
  • 371
  • 2
  • 5
  • 17

6 Answers6

28

Try this:

=LOWER(LEFT(A1)) & MID(SUBSTITUTE(PROPER(A1),"_",""),2,LEN(A1))

enter image description here

With Office 365 we can use:

=LET(
    rr,A1,
    x,TEXTSPLIT(rr,"_"),
    CONCAT(LOWER(TAKE(x,,1)),PROPER(DROP(x,,1))))

enter image description here

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
5

Just use =PROPER(A1) on the another cell and you have it done.

Baraka Mbega
  • 69
  • 1
  • 2
3

You were so close! Just wrap your left expression in a LOWER:

=LOWER(LEFT(A1)) & RIGHT(SUBSTITUTE(PROPER(A1),"_",""), LEN( SUBSTITUTE(A1,"_",""))-1) 
Chris Schaller
  • 13,704
  • 3
  • 43
  • 81
1
   =LOWER(LEFT(A1)) & MID(A1,2,LEN(A1))

This works perfectly for creating camel case when there is no space or underscore between words.

So HelloWorld will become helloWorld.

Jobin
  • 79
  • 3
  • 8
0

This converts to camel case:

=SUBSTITUTE(LOWER(LEFT(A5)) & MID(A5,2,LEN(A5)),"_","")
nullromo
  • 2,165
  • 2
  • 18
  • 39
Niki
  • 1
  • While this code snippet may be the solution, including a detailed explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Shawn Hemelstrand Apr 01 '23 at 02:12
-1

using replace,

=LOWER(LEFT(A1,FIND("_",A1)-1))&PROPER(REPLACE(A1,1,FIND("_",A1),""))