+ Reply to Thread
Results 1 to 6 of 6

Simple code to locate a word and remove space in front

  1. #1
    Registered User
    Join Date
    11-14-2011
    Location
    Dusseldorf, Germany
    MS-Off Ver
    Excel 2003
    Posts
    97

    Simple code to locate a word and remove space in front

    Hello,

    I need a code to locate some words from a list in Sheet2 and Column A
    in Sheet1 and Column C and remove the space in front of these words in Sheet1/Column C

    example
    sheet2
    word
    test

    sheet1 (should become after running the code)
    remove wordspace
    testspace
    wordare small
    space testshould go

    Thank you in advance.
    Last edited by yiannis1925; 12-13-2011 at 09:32 AM.

  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: Simple code to locate a word and remove space in front

    Try this:
    Please Login or Register  to view this content.
    _________________
    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
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: Simple code to locate a word and remove space in front

    something like:

    if there are more than 10 words, x will need to be changes to x = 1 to (number of words in list)

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: Simple code to locate a word and remove space in front

    rats.. someone beat me to it

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

    Re: Simple code to locate a word and remove space in front

    No worries, JF, we are a village. It's not a race...

    As a teaching forum, be sure to declare your variables.

    Also, your macro is making changes outside of column C due to your Cells. reference. Edit that back to just column C and remove the unnecessary .Select. And I believe the words to replace are on Sheet1.
    Last edited by JBeaucaire; 12-13-2011 at 08:38 AM.

  6. #6
    Registered User
    Join Date
    09-23-2010
    Location
    London, England
    MS-Off Ver
    2007
    Posts
    97

    Re: Simple code to locate a word and remove space in front

    ah yes..

    that could have made a mess
    cheers,

    J

+ 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