+ Reply to Thread
Results 1 to 12 of 12

Find Multiple Texts and Replace Texts / Blanks within a List of Texts

  1. #1
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Exclamation Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Hi All,

    I am looking for Excel Simple VBA Code to find multiple texts withing my data and replace with another text or blank (means delete).

    I have two sheets in the attached sample workbook.

    1. Data - this is where I have my data where I want to do the find and replace.

    2. Words Edit - In this sheet I have words in Column - G these words we need to find in the Data and Replace with Words in Column - H, if Column H is blank it means the word in Column - G needs to be found and deleted in the data.

    The Lists in Words Edit sheet to find starts with a space and ends with a space, this has been done to ensure that we would find and replace only whole words and not part of a word.

    e.g the first record in the Data Sheet:
    " SAM 1X 5059X DS 16GB - Black DE "

    The result should be - " Samsung 1X 5059X Dual Sim 16GB - Black "
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Please try

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Thumbs up Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Thank you for your response.

    I have tried the code. The results are satisfactory.

    I just did a small enhancement to the below line:

    c.Value = " " & c.Value & " " (so that we have a space in front as well as at the end)

    Thank you again and I will accept your response as the answer to my question.

  4. #4
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Unhappy Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Bo,

    I am experiencing some issues with the highlighted (in yellow) range in the attached file (Sample2).
    Seems in this range there are still words not replaced or deleted.
    I am unable to find the reason.

    Can you please check.
    Attached Files Attached Files

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    The space in highlighted is chr(160) (non-breaking space) not normal space chr(32)

    Please add red line
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Thumbs up Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Perfect

  7. #7
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Can you tell me how to find the "Chr(160)" like number for any character in a string ? I am sorry to ask you after long break...

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    If you mean Ctrl+F

    at any cell enter =CHAR(160) => press F9 => Press Ctrl+C => Press Ctrl+F => Press Ctrl+V => Click Find All

  9. #9
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    no, You didn't get my question.

    I am not asking how to find the character in the sheet.

    I am asking how you decide if its CHAR(160) or any other CHAR(???) is there a chart like this to refer to see what are all the Special Characters and the corresponding CHAR(#) listed.

  10. #10
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Sorry about that, but that is what I do first to check if there any Char(160)

    Please try at
    J912
    =MID($H912,COLUMNS($J912:J912),1)
    J913
    =CODE(J912)

    Drag J912:J913 to the right

    You will find 160 at AH913
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    06-01-2014
    Location
    Riyadh, Saudi Arabia
    MS-Off Ver
    Microsoft 365
    Posts
    224

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    Okay that was what I was looking for.

    Thanks a lot for that info.

    My colleague who is sitting in a different country is facing a problem when he run the macro. The special CHAR(160) does not get replaced in his PC.

    Does this have to do anything with location ?

  12. #12
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Find Multiple Texts and Replace Texts / Blanks within a List of Texts

    No, CHAR(160) could come from any other database, SQL, etc.

+ 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. Find specific multiple texts and define it
    By da.se in forum Excel General
    Replies: 9
    Last Post: 11-16-2017, 03:38 AM
  2. finding the 3rd to 5th texts in a series of texts
    By managingcrap in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2016, 11:39 PM
  3. [SOLVED] Formula to extract row / right last texts for given texts
    By thilag in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2015, 02:51 AM
  4. Replies: 9
    Last Post: 07-02-2015, 01:13 AM
  5. [SOLVED] To average cells included texts - how to ignore texts in those cells - help please
    By PrayoonD in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-23-2014, 12:32 PM
  6. Automatically find and replace texts and numbers
    By a_27826 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-19-2013, 01:22 PM
  7. [SOLVED] How to Find and Replace a string if cell does not contain certain texts.
    By windcloud2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2012, 01:04 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