Extract 4 characters in no specific order - Microsoft Community
Office / Excel / Windows 10 / Office 2013
hi, need extract 4 characters in uppercase each cell, dont come in same order need help:
example:
c dry gin ale-ko btcn 237ml alcn n 1ls 12 |
c dry gin ale-ko 355ml alcn n 1ls 12 |
c dry tonic-ko 355ml alcn n 1ls 12 |
c dry gin ale-ko post 9.5lt cdbb n 1ls |
c dry soda wtr-ko btcn 2lt plbt n 1ls 6 |
fresca btcn 2.5lt plbt n 1ls 6 |
fresca btcn 3lt plbt n 1ls 6 |
i need extract first 4 uppercase characters in order have:
btcn
alcn
post
btcn
btcn
btcn
thanks
here simple udf coded in vba
best wishes
function findfour(mycell)
mytext = mycell.value
for k = 1 len(mytext) - 3
myfour = mid(mytext, k, 4)
mycount = 0
j = 1 4
mychar = mid(myfour, j, 1)
if asc(mychar) >= 65 , asc(mychar) <= 90 mycount = mycount + 1
next j
if mycount = 4 then
findfour = myfour
exit for
end if
next k
end function
Office / Excel / Windows 10 / Office 2013
Comments
Post a Comment