+ Reply to Thread
Results 1 to 11 of 11

Separating alpha, numeric and other characters

  1. #1
    Registered User
    Join Date
    03-19-2010
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2003
    Posts
    1

    Separating alpha, numeric and other characters

    Hi All,

    I am looking for a formula that will help seperate alpha, numeric and other characters within a string.

    Here are a few examples sw12-24, v9-17, SL7-19W

    What I need to pull is just the numeric part of data 12-24, 9-17 and 7-19.

    Any suggestions?

    ldg

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Separating alpha, numeric and other characters

    I would add a custom function to your workbook to do this with a formula that's sane to look at. A User Defined Function (UDF) to do what you want called CLEANALL can be used.

    Here's the code:
    Please Login or Register  to view this content.
    =========
    How to install the User Defined Function:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    ===========
    How to Use the UDF

    Place the strings in a column...let's use column A. The formula in B1 would be:

    =CLEANALL(A1)
    ...just copy that down.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-21-2008
    Location
    Mumbai,India
    Posts
    4

    Re: Separating alpha, numeric and other characters

    =1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW(1:10),1)),0),COUNT(1*MID(A1,ROW(1:10),1)))

    Important You must enter these formulas as arrays by pressing CTRL+SHIFT+ENTER.

    for sw12-24 you will have to insert sw1224 the the array formula will give you 1224 then you can use a concatenate function to separate the month and date

    i hope this is of sum help

  4. #4
    Registered User
    Join Date
    05-31-2014
    Posts
    1

    Re: Separating alpha, numeric and other characters

    Very nice.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Separating alpha, numeric and other characters

    A bit long but here it is

    =LEFT(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890)),25),MATCH(1,-MID(MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&1234567890)),25),{1,2,3,4,5,6,7,8,9,0},1)))

    Row\Col
    A
    B
    1
    sw12-24 12-24
    2
    v9-17 9-17
    3
    SL7-19W 7-19
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Expert boopathiraja's Avatar
    Join Date
    07-12-2013
    Location
    Coimbatore,TamilNadu, India
    MS-Off Ver
    Excel 2007, 2013, 2016, 365
    Posts
    1,455

    Re: Separating alpha, numeric and other characters

    HI Try this



    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Click just below left if it helps, Boo?ath?

  7. #7
    Registered User
    Join Date
    05-26-2015
    Location
    Dubai
    MS-Off Ver
    2010
    Posts
    15

    Re: Separating alpha, numeric and other characters

    Hello JBeaucaire..

    Thank you for the help on splitting up alphanumeric cell content.

    Is there anyway to alter the formula/code to split out numbers and characters from text?

    For example - separating : R.S. ELITNIY 87% KAKAO BG 100G NU into 87%100
    FIKSI SO SHOK.-OREKHOV.NACH.BM 45G VOE(N into .-..45(

    Please help!

    Thank you!

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Separating alpha, numeric and other characters

    My function shows how to extract numbers OR text. You simply comment out one line and activate the other.

    So if you need to do BOTH, create two versions of that function with different function names. Change CleanALL to NumOnly and in the second one TextOnly, as an idea.

  9. #9
    Registered User
    Join Date
    05-26-2015
    Location
    Dubai
    MS-Off Ver
    2010
    Posts
    15
    Quote Originally Posted by JBeaucaire View Post
    My function shows how to extract numbers OR text. You simply comment out one line and activate the other.

    So if you need to do BOTH, create two versions of that function with different function names. Change CleanALL to NumOnly and in the second one TextOnly, as an idea.

    Hello again,

    Thank you for the response. The thing is... I am trying to have numbers and symbol characters taken out... Ie leave all letters behind and strip out all the rest.

    Is there a way to do that, please?

    Thank you again.

  10. #10
    Registered User
    Join Date
    05-26-2015
    Location
    Dubai
    MS-Off Ver
    2010
    Posts
    15

    Re: Separating alpha, numeric and other characters

    Oh and... What does comment out mean? Sorry, not as clued up as most of the guys on here.

    Thank you.

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Separating alpha, numeric and other characters

    An apostrophe in VBA starts a "comment", so adding one to a line of code effectively turns it off while note deleting it.
    Original with comments in green:
    Please Login or Register  to view this content.
    So you can create versions of this by changing the name of the function and then editing which line is commented and which is is not.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1