excel - VBA: Put a space after or before a upppercase letter in a string -


i have sequence of texts represent customers names, not have spaces between each word/name (for example: johnwilliamssmith). words can differentiated because first letter of each word uppercase.

so need transpose list of customers strings regular format, spaces between each word. want johnwilliamssmith become john williams smith. however, couldn't think of immediate way achieve this, , believe no combination of excel formulas can offer result.

thus, think solution set macro. might function used formula, or code in module work data in range (imagine list in range ("a2: a100")).

does have idea how can this?

function addspaces(pvalue string) string    dim xout string   xout = vba.left(pvalue, 1)    = 2 vba.len(pvalue)     xasc = vba.asc(vba.mid(pvalue, i, 1))      if xasc >= 65 , xasc <= 90       xout = xout & " " & vba.mid(pvalue, i, 1)     else       xout = xout & vba.mid(pvalue, i, 1)     end if    next   addspaces = xout end function 

nb: use function formula =addspace(a1).


Comments