excel - VBA, 'Left' Different Strings Dynamically -
having trouble shortening strings in column making dynamic directory. ex: 3 strings in column, 1 string may continue 10 rows, string 20 rows, , 15 rows. each needing shorted different amount
specifically: had several words either sepearated -, _ , +. example 1 sheet has pv01_52352, pv+50, pv-100, irvega_242422, irvega word works. pv's struggling with. desired results works before special characters, pv01, pv , irvega desired result .
how can use left or anyway shorten these all? quite hard me since 1 string ill need first 4 characters, 5 characters shortened , need done throughout workbook.
any input appreciated, thanks.
i've found determining ascii character number code function (using upper function reduce possibilities) produces satisfactory results.
the array formula in b2 strictly alphabetic characters is,
=left(a2, min(row(indirect("1:"&len(a2)))+((code(mid(upper(a2), row(indirect("1:"&len(a2))), 1))>64)*(code(mid(upper(a2), row(indirect("1:"&len(a2))), 1))<91))*1e+99)-1)
an array formula in b2 alphanumeric characters is,
=left(a2, min(row(indirect("1:"&len(a2)))+(((code(mid(upper(a2), row(indirect("1:"&len(a2))), 1))>64)*(code(mid(upper(a2), row(indirect("1:"&len(a2))), 1))<91))+((code(mid(a2, row(indirect("1:"&len(a2))), 1))>47)*(code(mid(a2, row(indirect("1:"&len(a2))), 1))<58)))*1e+99)-1)
array formulas need finalized ctrl+shift+enter↵.
a vba user defined function (aka udf) strictly alphabetic characters be,
function just_the_alpha(str string) dim tmp string, c long c = 1 len(str) if asc(mid(ucase(str), c)) > 64 , _ asc(mid(ucase(str), c)) < 91 tmp = tmp & mid(str, c, 1) else exit end if next c just_the_alpha = tmp end function
a vba udf alphanumeric characters be,
function just_the_alphanum(str string) dim tmp string, c long c = 1 len(str) if (asc(mid(ucase(str), c)) > 64 , _ asc(mid(ucase(str), c)) < 91) or _ (asc(mid(str, c)) > 47 , _ asc(mid(str, c)) < 58) tmp = tmp & mid(str, c, 1) else exit end if next c just_the_alphanum = tmp end function
Comments
Post a Comment