+ Reply to Thread
Results 1 to 8 of 8

How to find position of capital letter in a text string?

  1. #1
    Registered User
    Join Date
    02-18-2007
    Location
    Manila / Philippines
    Posts
    42

    How to find position of capital letter in a text string?

    Hi Guys,

    I have a database of textstrings where a lot of them start with some numbers or lower case letters. I want to eliminate them as all important information always start with the first capital letter of a text string. How can I find out what is the position of the first capital letter, so that I can delete all characters in front of them?

    Any suggestion?

    Cheers,
    hegisin

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    An example of data would b good and expected results

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by hegisin
    Hi Guys,

    I have a database of textstrings where a lot of them start with some numbers or lower case letters. I want to eliminate them as all important information always start with the first capital letter of a text string. How can I find out what is the position of the first capital letter, so that I can delete all characters in front of them?

    Any suggestion?

    Cheers,
    hegisin
    Try this, if your text string is in A2, then in B1:AA1, put the letters of the alphabet in CAPS
    Then in B2 put this
    =IF(ISERROR(FIND(B$1,$A2,1)),"",FIND(B$1,$A2,1)) and drag across to AA2
    Then in AB2 put this
    =MIN(B2:AA2)
    Then in AC2 put this
    =MID(A2,AB2,100), if the text is long that 100 characters, adjust to suit.
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  4. #4
    Registered User
    Join Date
    02-18-2007
    Location
    Manila / Philippines
    Posts
    42
    Thanks for your quick replies!

    @Odlchippy, I will try that out.

    @VBA Noob:

    A typical dataset would look like that:

    1Mountain (IRE)Jonjo OŽNeill 4 10-12A P McCoy SP 1.83 fav
    2 1 Counting House (IRE)J A B Old 4 10-12 Jason Maguire SP 41
    3 3 Ned Ludd (IRE)J G Portman 4 11-3 Robert Thornton SP 4.5
    4 7 Pommerol (FR)F Doumen 4 11-0 t A Duchene(3) SP 5.5
    5 2 Dynamic Rhythm (USA)G Brown 4 10-5 Miss L Horner(7) SP 67
    6 13 GabierG L Moore 4 10-12 Jamie Moore SP 21
    7 5 Kinetic Power (IRE)N J Hawke 4 10-7 Mr J Snowden(5) SP 101
    8 3 Pepito Collonges (FR)Mrs L J Mongan 4 10-12 Leighton Aspell SP 67
    9 6 HonourŽs Dream (FR)T R George 4 10-12 Wayne Hutchinson SP 26
    10 26 Moonlight Music (IRE)K C Bailey 4 10-5 Alan OŽKeeffe SP 101
    F Sir Rique (FR)P J Hobbs 4 10-12 Richard Johnson SP 15
    PU Steak N Kidney (USA)M Wigham 4 10-12 Joe Tizzard SP 101


    This is from horse racing.

    My final target is to create data set, which includes horse name and price:

    Mountain 1.83
    Counting House 41
    Ned Ludd 4.5
    Pommerol 5.5
    .
    .
    .
    Steak N Kidney 101

    I was thinking, since Excel can change lower case to upper case in a function , it should have a method somehow to identify capital letters.

    Thanks for your help.

    Cheers,
    hegisin

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    This is a close as I could get

    Amended version

    http://www.savefile.com/files/501387

    I use this add-in to find the first Capital letter

    http://xcell05.free.fr/

    VBA Noob
    Last edited by VBA Noob; 02-18-2007 at 03:43 PM.

  6. #6
    Registered User
    Join Date
    02-18-2007
    Location
    Manila / Philippines
    Posts
    42
    Hi old chippy!

    I tried your method and it really works. I have to study the formular a little bit more in detail in order to understand why it works, though

    However, I'm still left with one problem. After I have converted a set of data, I still have to sort it. Unfortunately Excel does not allow me to do so with this set.

    Any further trick that I could use here?

    Many thanks for your kind help.

    Cheers,
    hegisin

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    This formula will give you the first capital letter in A1

    =MID(A1,MIN(FIND(CHAR(ROW(INDIRECT("65:90"))),A1&"ABCDEFGHIJKLMNOPQRSTUVWXYZ")),1)

    confirmed with CTRL+SHIFT+ENTER

  8. #8
    Registered User
    Join Date
    02-18-2007
    Location
    Manila / Philippines
    Posts
    42
    Hi all,

    First of all I have to say that I'm quite impressed with this forum and very fast response.

    I certainly will use it frequently from now on.

    @ VBA Noob

    Very cool add-on functions. Thanks for that. I will fine tune the formula now according to my requirements.

    @ daddylonglegs

    The formula is working fine if I want to do the search within one particular cell. But how would I make it work for a dataset (lets say a1:a10)?

    Also please let me know how to modidy the formula, if I wanted to know just the position number of the capital letter within the string.

    Thanks all!

    hegisin

+ 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