Excel 2010/2013 Excel 2007 Excel 2003 Tips & Tricks Excel Forum Course Index CIG Excel Book

 Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us More... What's New? Tips & Tricks Access Index Access Tips Excel Index Excel Tips Waiting List

 News      User Comments     History     Notify Me

8/18/2010 5:47:12 PM
Excel Tip: Breaking Up Text Strings
By Richard Rost

Since I'm back in the groove making videos, I posted a short 5 minute Excel Tip on breaking up text strings.

Ever get a sheet full of names like "Joe Smith" and you need to break them up into first name, last name in separate columns? I'll show you how in this tutorial.

- Excel Tip: Breaking Up Text Strings

Enjoy.

Permanent Link
Keywords: excel tips text sttrings find len left right
 Post Reply

Excel Tip Breaking Up Text Strings Comment from Alex Hedley @ 8/12/2012
 Hi Ritesh,How is your VBA?A quick google search found the following:[http://www.pcreview.co.uk/forums/split-astring-using-capital-letter-identifier-t3855968.html]The first loops through the word, checking if the letter it is looking at is an Uppercase letter [UCase()] and if so adds a space between it.'Usage=SplitWords(A1)Function SplitWords(strData) As String  Dim intTemp As Integer  SplitWords = Left(strData, 1)  For intTemp = 2 To Len(Trim(strData))    If Mid(strData, intTemp, 1) = UCase(Mid(strData, _      intTemp, 1)) Then SplitWords = SplitWords & " "      SplitWords = SplitWords & Mid(strData, intTemp, 1)  NextEnd Function--The next checks the ASCII value [Asc()]. If it is in the range of an Uppercase letter (A - 65, Z - 90) split it.(http://www.asciitable.com/)Function splitcap(wholestr)  splitstr = ""  For i = 1 To Len(wholestr)    currchr = Mid(wholestr, i, 1)    splitstr = splitstr & IIf(Asc(currchr) < 91 And i > 1, " ", "") &    currchr  Next i  splitcap = splitstrEnd Function--This one uses string matchingFunction SplitOnCaps(S As String) As String  Dim X As Long  SplitOnCaps = S  For X = Len(SplitOnCaps) To 2 Step -1    If Mid(SplitOnCaps, X, 1) Like "[A-Z]" Then      SplitOnCaps = Left(SplitOnCaps, X - 1) & " " & Mid(SplitOnCaps, X)    End If  NextEnd Function--Will there only be ever 1 uppercase to split on? This will do it for any, an example was "FirstnameMiddlenameLastname"=====================================Option ExplicitFunction SplitOnCaps(s As String) As String  Dim re As Object  Set re = CreateObject("vbscript.regexp")  re.Global = True  re.Pattern = "([a-z])([A-Z])"  SplitOnCaps = re.Replace(s, "\$1 \$2")End Function======================================--Each uses a different method and is useful for showing how different in built functions work.I haven't tested these but the appear to be fine, many thanks to the other guys in the forum for writing this, saved me doing it :pRegardsAlex Show Just This Thread        Post Reply
Excel Tip Breaking Up Text Strings Comment from ritesh @ 8/10/2012
 i want space in one single line , eg - ChrisTalbert  = Chris Talbert.ChristensenAl = Christensen Al. ChristensenJennifer = Christensen Jennifer. Show Just This Thread        Post Reply
want to learn Comment from shoby @ 11/27/2010
 want to learn excel.Reply from Richard Rost:Great. You've come to the right place, then. :) Show Just This Thread        Post Reply

Add Your Comments or Subscribe
 If you just want to subscribe to get email updates when the News is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome. Your Name: Required Your Email: NOT Public Subject: Comments: Sorry about this step. It's just to keep the spam bots away: Verify: What is 6+4: Notify me when the News is updated. Remember Me for my next comments Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead. I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be. As always, I promise to never give away your personal information to anyone else, ever. NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard

 You may want to read these articles from the 599CD News:
 5/4/2014 Microsoft Access Expert 20 3/5/2013 Excel Tip: Price Markups 2/3/2013 Signed Copies of my Excel Book 9/27/2012 Excel Expert 10 Handbook Ready 9/18/2012 Two New Excel Tips: Date/Time Differences 6/20/2012 Excel Tip: Sum Cells Between Two Values 6/16/2012 New Excel Tip: Paste Link 3/26/2012 Excel Tip: 2D Matrix Lookups 11/18/2011 Dashboards in Excel 10/6/2011 Excel Expert 11 On Hold

Learn

 Access index Excel index Word index Windows index PowerPoint index Photoshop index Visual Basic index ASP index Seminars More...
Customers

Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Change Email
Info

Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Help

Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us

Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order

Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact

Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey