+ Reply to Thread
Results 1 to 10 of 10

Need to remove the first 2 characters in string plus spaces on the left with macro

Hybrid View

abjac Need to remove the first 2... 10-13-2014, 08:45 AM
Marc L Re: Need to remove the first... 10-13-2014, 08:51 AM
abjac Re: Need to remove the first... 10-13-2014, 09:03 AM
abjac Re: Need to remove the first... 10-13-2014, 02:46 PM
Marc L Re: Need to remove the first... 10-14-2014, 02:45 AM
JOHN H. DAVIS Re: Need to remove the first... 10-14-2014, 07:01 AM
abjac Re: Need to remove the first... 10-14-2014, 12:16 PM
JOHN H. DAVIS Re: Need to remove the first... 10-14-2014, 03:35 PM
abjac Re: Need to remove the first... 10-14-2014, 03:51 PM
JOHN H. DAVIS Re: Need to remove the first... 10-15-2014, 06:11 AM
  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,120

    Need to remove the first 2 characters in string plus spaces on the left with macro

    Hi I need help to remove the first 2 characters in string in column A.
    I need a macro for it because its part of bigger sort.
    The 2 first characters and also if it can remove spaces in the left in the text it will be great.

    Below is a text string. To put in cell A2. Please have a look I need a macro for it.

    Here is an example of the string with spaces also

    Please have a look

    Sincerely
    Abjac



       ..        280714    B2A2498900 GBP    37,728.00  PAY             00666676
    Wanted result will be

    280714    B2A2498900 GBP    37,728.00  PAY             00666676

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

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro


    Hi,

    you can combine Mid function from character #3 with LTrim function

    or using Mid function only if needed string starts always from same position …

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,120

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    Hi MArc and thanks. Could you show how it will look in a macro please.

    Thanks in advance

    Abjac

  4. #4
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,120

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    HI Is it possible to do this with a macro or shall or do i need to use formula. Macro would be best because its part of much sorting.

    Sincerely
    Abjac

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

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro


    These functions are in VBA inner help, very beginner level …

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    Maybe:

    Sub abjacvv()
    Range("A2") = Right(Range("A2"), Len(Range("A2")) - 2)
    Range("A2") = LTrim(Range("A2"))
    End Sub

  7. #7
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,120

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    Hi John and thanks for the answer. I works great really just as it have to do. How to put a range on it ?, or to last used cell in column A?
    Thanks

    Sincerely

    Abjac

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    Maybe:

    Sub abjacvv()
    Dim i As Long
    For i = 2 To Range("A" & Rows.count).End(3).Row
    Range("A" & i) = Right(Range("A" & i), Len(Range("A" & i)) - 2)
    Range("A" & i) = LTrim(Range("A" & i))
    Next i
    End Sub

  9. #9
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,120

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    Hi John. It works just brilliant. Thanks allot for you help. Its really great.

    Have a nice evening

    Sincerely'
    Abjac

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Need to remove the first 2 characters in string plus spaces on the left with macro

    You're welcome. Glad to help out and thanks for the feedback.

+ 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 spaces and characters in hyperlink - macro
    By missy22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2013, 09:23 AM
  2. Replies: 8
    Last Post: 12-17-2012, 05:30 AM
  3. [SOLVED] remove spaces (special characters) after numbers
    By fareastwarriors in forum Excel General
    Replies: 13
    Last Post: 11-04-2012, 09:25 PM
  4. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  5. Remove All Text,Special Characters, & Spaces
    By g48dd in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-01-2011, 09:24 AM

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