View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Split field based on number of characters and space

s = cell.Value
if len(s) < 30 then exit sub
iloc = Instr(1,s," ",vbTextCompare)
if iloc < 30 and iloc < 0 then
s1 = left(s,iloc-1)
s2 = mid(s,iloc+1,255)
else
s1 = left(s,30)
s2 = Mid(s,31,255)
end if

--
Regards,
Tom Ogilvy

"william_mailer"
<william_mailer.22x0oz_1139409913.2219@excelforu m-nospam.com wrote in
message news:william_mailer.22x0oz_1139409913.2219@excelfo rum-nospam.com...

I have a string of text in a cell. I want to split the cell based on
anything over 30 characters. But I want to also split on a space. So
basically the first space before I reach 30 characters limit. Hope I
explained well !! Any help would be great !

Thanks


--
william_mailer
------------------------------------------------------------------------
william_mailer's Profile:

http://www.excelforum.com/member.php...o&userid=31318
View this thread: http://www.excelforum.com/showthread...hreadid=510057