+ Reply to Thread
Results 1 to 17 of 17

How to remove space after a particular character

  1. #1
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    How to remove space after a particular character

    Hi everyone,

    I am in need of a help. I have a notepad with some values. In this notepad I would like to remove spaces (if any) after this character ~

    For Example if the line in the notepad reads as

    Hello*1234*Good Morning~ Thank you

    Then I would like to change it to

    Hello*1234*Good Morning~Thank you

    Please note the space between ~ and Thank you. I want only that space to be removed. and this occurs many times in the notepad each time only the space next to ~ has to be removed.

    Is this possible. Please help. Thanks in advance

  2. #2
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to remove space after a particular character

    - open that file by notepad
    - press ctrl+H for Replace text
    - at: Find what textbox type ~ and space
    - at Replace with textbox type only ~ (without any space)
    - then press Replace or Replace all
    Best regard, -)iger-/iger
    If you are pleased with a solution mark your post SOLVED.

  3. #3
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Actually I need this to be done in Macro.
    I tried replaceall method via vba. But that didn't do the trick.

  4. #4
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to remove space after a particular character

    Quote Originally Posted by sugaprasad View Post
    Actually I need this to be done in Macro.
    I tried replaceall method via vba. But that didn't do the trick.
    oh, why don't you said more clear before?

    Try the code
    (untested)

    Please Login or Register  to view this content.
    reference at: http://stackoverflow.com/questions/1...eas-close-file

  5. #5
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Thank you. it worked. That's all I wanted.

  6. #6
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to remove space after a particular character

    Please, Mark SOLVED for this topic by edit your first post and click mark solved

  7. #7
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    I marked the thread as solved. Thank you

  8. #8
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Hi.

    sorry to open the same thread again.

    A sudden change in the requirement. I need to delete anything that follows ~ character.

    Taking same example again

    Hello*1234*Good Morning~%Thank you should be changed to Hello*1234*Good Morning~Thank you

    another example

    Hello*1234*Good Morning~$Thank you should be changed to Hello*1234*Good Morning~Thank you

    Thanks in advance

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to remove space after a particular character

    Try
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Hi Jindon. Thank you for the help. I used your code and I am getting Type mismatch error when the For loop starts. Any idea? Thanks again

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to remove space after a particular character

    Try this then.
    If still error, need to see your data.
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Thankyou. I guess you will need my code. My requirement is below

    1. pick a target textpad file where characters after ~ has to be removed ( done coding and working)
    2. Remove the characters after ~ (got stuck here)

    My code for you

    Please Login or Register  to view this content.
    I appreciate your help

  13. #13
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to remove space after a particular character

    Quote Originally Posted by sugaprasad View Post
    Thankyou. I guess you will need my code. My requirement is below

    1. pick a target textpad file where characters after ~ has to be removed ( done coding and working)
    2. Remove the characters after ~ (got stuck here)

    My code for you
    ........
    I appreciate your help
    you adjust the bellow code to appropriate to your problem
    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to remove space after a particular character

    Is this what you wanted to do?
    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Thank you tigertiger. Your code is working fine.

    Thanks much Jindon.

    as for now I am keeping this thread in open as I am doing few more changes. Once I am done, I will mark the thread as solved

  16. #16
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to remove space after a particular character

    Hi,

    I need one more favor. your latest code is working fine but for one thing which i anticipated.

    For example consider the notepad has two lines like this -

    Hello*1234*Good Morning~$
    Thank you


    Then it perfectly removes the $ after the ~

    Now lets consider the same case without any character after ~ like this -

    Hello*1234*Good Morning~
    Thank you


    then the output after the execution of code looks like this

    Hello*1234*Good Morning~Thank you

    I mean the second line merges with the first line if there are no characters after ~. I would like this not to happen. If there are no character after ~ it shouldn't merge the two lines to one. It should leave as it is.

    Can you please help. I know this is too much of me to ask and I wasn't clear on the requirements before. My sincere apologizes.

  17. #17
    Valued Forum Contributor
    Join Date
    11-11-2008
    Location
    Euro
    MS-Off Ver
    2007, 2010
    Posts
    470

    Re: How to remove space after a particular character

    Quote Originally Posted by sugaprasad View Post
    Hi,
    ..............
    I mean the second line merges with the first line if there are no characters after ~. I would like this not to happen. If there are no character after ~ it shouldn't merge the two lines to one. It should leave as it is.
    ......
    You use the code at post #13, and replace the function

    Quote Originally Posted by tigertiger View Post
    you adjust the bellow code to appropriate to your problem
    Please Login or Register  to view this content.
    to this

    Please Login or Register  to view this content.

+ 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. Replies: 0
    Last Post: 08-19-2014, 11:02 AM
  2. Remove Space from first character of text
    By jaymkent in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2012, 07:19 AM
  3. Replies: 3
    Last Post: 11-20-2012, 10:03 PM
  4. [SOLVED] If Cell Starts with a Space, remove that space
    By Ocean Zhang in forum Excel General
    Replies: 2
    Last Post: 09-29-2012, 01:52 PM
  5. Remove space and "-" character
    By thanhnguyen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-04-2006, 11:50 PM

Tags for this Thread

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