Extract 4 characters in no specific order - Microsoft Community


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

Popular posts from this blog

Getting ErrorCode: 120018 when trying to access Microsoft account - Microsoft Community

The message was sent to a distribution list ‎(DL)‎ - Microsoft Community

What is the Office 365 default group Mailbox Users ISV Access Enabled - Microsoft Community