+ Reply to Thread
Results 1 to 11 of 11

search & replace macro

  1. #1
    Registered User
    Join Date
    12-12-2006
    Posts
    63

    search & replace macro

    Hi, I'm using search & replace in a macro but only want to replace the text if it is in the first 3 letters within the cell. So, for example, I currently have;


    Please Login or Register  to view this content.

    This is to delete the text "DS" but obviously it's deleting DS anywhere within the text rather than just at the beginning of the text.

    any help much appreciated.

    Liam
    Last edited by LiamF; 07-30-2010 at 06:57 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: search & replace macro

    Hi LiamF

    maybe something like
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: search & replace macro

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  4. #4
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: search & replace macro

    Since you already have your code, add this about the code (but change the column to the column your data is in...

    Please Login or Register  to view this content.
    Your finished code will look like this....

    Please Login or Register  to view this content.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: search & replace macro

    Hi Shaner73
    Doesnt the code will still replace DS any where in the text?

  6. #6
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: search & replace macro

    I think
    Please Login or Register  to view this content.
    should be replaced with
    Please Login or Register  to view this content.
    hth
    Ajay

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: search & replace macro

    Hmmm. same problem with samples
    DSAAAA
    AADSAA
    AAAADS

  8. #8
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: search & replace macro

    Sorry, I missed the following in original post.

    replace the text if it is in the first 3 letters

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: search & replace macro

    Hi ajaykgarg
    No that doesnt work
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: search & replace macro

    Pike, you are correct. I didn't read the original post well enough. I took his post as "DS" was being removed from all columns and rows. My apologies.

    In the mean time, I'm looking to see if I have anything else that may be able to help him.

  11. #11
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,787

    Re: search & replace macro

    Perhaps something like this

    Please Login or Register  to view this content.
    HTH

    Alf
    Last edited by Alf; 08-04-2010 at 04:15 PM. Reason: Better answar

+ 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