Remove text string from excel that is separated by * and / -
i have column of cells contain samples of following
a1 = d11f2/j3c2/fence*25a/23a/21a/20a a2 = d11f2/00a/123/d6f2
i want remove 3 digit codes "/00a" separated / in case in a1 separated star "*25a"
this formula/macro result in:
a1 = d11f2/j3c2/fence a2 = d11f2/d6f2
thanks help!
i tried using substitute formula removed first or second string after divider
the following vba function appears understand asking for:
function stripthree(s string) ' find sequence of 3 "digits" ' separated either ' ', '*', or '/' ' , remove them, including leading separator dim ii, l, lastgood, lastsep integer dim retval string lastgood = 0 lastsep = 0 ii = 1 len(s) l = mid(s, ii, 1) retval = retval & l if l = "/" or l = "*" or l = " " if ii - lastsep = 4 retval = left(retval, len(retval) - 5) & l end if lastsep = ii end if next ii ' if last "separator" end of string ' still need remove 3 digit/letter code if lastsep + 4 = ii retval = left(retval, len(retval) - 4) end if stripthree = retval end function
examples of code @ work:
input: d11f2/j3c2/fence*25a/23a/21a/20a output: d11f2/j3c2/fence input: d11f2/00a/123/d6f2 output: d11f2/d6f2
as stipulated in question.
Comments
Post a Comment