+ Reply to Thread
Results 1 to 18 of 18

remove after three & four letters , keep the first three & four letters with shift capital

  1. #1
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    remove after three & four letters , keep the first three & four letters with shift capital

    hi guys !
    I have some words (JAPAN,THAILAND,INDONESIA) and somtimes small letter for some the items . so any item contains (JAPAN,THAILAND,INDONESIA) should delete the letters after three or four letters then should be (JAP,THI,INDO) and if any items contain letter is small then should convert to capital letters . I put the result in second sheet , but should be in the first sheet .
    thanks
    Attached Files Attached Files
    Last edited by abdo meghari; 04-30-2022 at 06:08 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi, try this !


    According to your attachment a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
            
    Dim VR&, L&
        
    With [A1].CurrentRegion.Columns(2)
                
    = .Value
            
    For 2 To .Rows.Count
                L 
    InStrRev(V(R1), " ")
                
    V(R1) = Left(V(R1), L) & UCase(Mid(V(R1), 13))
            
    Next
               
    .Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    thanks , but "INDONESIA" should be "INDO" as I siad . your code make it IND .

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    There needs to be a logic for which should contract to 3 and which to 4, or you'll need a lookup list.

    You have misspelt THAILAND, by the way.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: remove after three & four letters , keep the first three & four letters with shift cap


    Quote Originally Posted by abdo meghari View Post
    thanks , but "INDONESIA" should be "INDO" as I siad . your code make it IND .
    Is 'INDONESIA' the only one to need one more character ?!

  6. #6
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    There needs to be a logic for which should contract to 3 and which to 4, or you'll need a lookup list.
    JAPAN=JAP,THAILAND=THI,INDONESIA=INDO

    You have misspelt THAILAND, by the way.
    thanks for inform me

  7. #7
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    Is 'INDONESIA' the only one to need one more character ?!
    yes this is the only

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    So THAILAND will shorten to THA or THI???

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: remove after three & four letters , keep the first three & four letters with shift cap


    Hoping it is obviously 'THA' for Thailand in order to avoid a gas factory procedure …

  10. #10
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    So THAILAND will shorten to THA or THI???
    again sorry! you're right, but it doesn't make difference because just delete after first three letters .it's not important who's the third letter should delete after it , A or I

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Try this …


    My VBA demonstration revamped :

    PHP Code: 
    Sub Demo1r()
            
    Dim VR&, S
        With 
    [A1].CurrentRegion.Columns(2)
                
    Application.Trim(.Cells)
            For 
    2 To .Rows.Count
                    S 
    Split(V(R1))
                If 
    UBound(S) = 2 Then
                    S
    (2) = UCase(S(2))
                    
    S(2) = Left(S(2), - (S(2Like "INDO*"))
                    
    V(R1) = Join(S)
                
    End If
            
    Next
               
    .Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  12. #12
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    Hoping it is obviously 'THA' for Thailand in order to avoid a gas factory procedure …
    based on your code I think to don't affect for code working if the letter is wrong

  13. #13
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    @Marc L great! this is what I need it. except the last item doesn't convert small letter to capital letter . see the letter r
    Last edited by abdo meghari; 04-30-2022 at 06:32 AM.

  14. #14
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    @Marc L edited last post

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: remove after three & four letters , keep the first three & four letters with shift cap


    As it well works on my side with your initial post attachment where I can't find what you describe …

  16. #16
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    sorry ! the item 42 in row43 235/85r16 D697 INDO should be 235/85R16 D697 INDO .

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Check this !


    As finally it is not only for the third word so my revamped demonstration revised :

    PHP Code: 
    Sub Demo1r2d2()
            
    Dim VR&, S
        With 
    [A1].CurrentRegion.Columns(2)
            
    Evaluate("IF({1},UPPER(TRIM(" & .Address ")))")
        For 
    2 To .Rows.Count
            S 
    Split(V(R1))
            If 
    UBound(S) = 2 Then S(2) = Left(S(2), - (S(2Like "INDO*")): V(R1) = Join(S)
        
    Next
           
    .Value V
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  18. #18
    Forum Contributor
    Join Date
    12-02-2020
    Location
    Asia
    MS-Off Ver
    2010 & 2016 insider(Windows 10 64-bit)
    Posts
    729

    Re: remove after three & four letters , keep the first three & four letters with shift cap

    and if any items contain letter is small then should convert to capital letters
    I mentioned it , if it's not clear this is my bad ! sorry !
    thanks very much for your assistance

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Remove any letters except the capital letters
    By mactrading in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 11-25-2021, 07:24 AM
  2. [SOLVED] Not differentiating between capital letters and lower case letters
    By Eliot Y in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-22-2015, 11:13 AM
  3. Capital letters
    By alan h m in forum Excel - New Users/Basics
    Replies: 15
    Last Post: 02-08-2015, 08:19 PM
  4. Capital letters
    By NadineJordy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-10-2013, 06:20 AM
  5. Replies: 13
    Last Post: 07-08-2012, 11:26 PM
  6. Capital letters
    By m.cain in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2007, 03:48 PM
  7. capital letters
    By HGood in forum Excel General
    Replies: 5
    Last Post: 01-11-2005, 11:06 PM

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