+ Reply to Thread
Results 1 to 9 of 9

Highlight a set of data from column D and remove the same words from Column E

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    30

    Talking Highlight a set of data from column D and remove the same words from Column E

    Hi all ,
    I am relatively new to Excel and VBA , i have been writing a code where i want to remove a set of words from column E and i need to highlight the same set of words in column D ;


    The columns before running the macro

    Column D
    ----------------------
    red color
    blue sky
    green rocket

    Column E
    ----------------------
    red color
    blue sky
    green rocket




    After columns running the macro with the set of words ( red , blue , green )

    Column D
    ---------------------------
    red color
    blue sky
    green Rocket

    Column E
    ---------------------------
    color
    sky
    Rocket


    I have recorded the macro and been using the find and replace statements . The problem with this is the number of rows i have are around 20,000 to 30,000 . So i need the macro to work efficiently and as quickly as possible . Any help would be appreciated.
    Last edited by rampulaparthi; 07-30-2013 at 11:29 AM.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Highlight a set of data from column D and remove the same words from Column E

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-20-2013
    Location
    hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Highlight a set of data from column D and remove the same words from Column E

    Thanks yudlugar ,

    Sorry for being a total rookie, but can you tell me the code change i can do if i want this to work on a set of words where as in
    target_word = "red","blue","green"

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Highlight a set of data from column D and remove the same words from Column E

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Highlight a set of data from column D and remove the same words from Column E



    you sir take my like ..

    added reputation and closing this thread

  6. #6
    Registered User
    Join Date
    06-20-2013
    Location
    hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Highlight a set of data from column D and remove the same words from Column E

    oh and one more quick question ,

    What if i want to delete the String which is there in column B and column C from the data in column E , would be again 1 or 2 more lines of code can you add that for me in the above code ? I have crude way of doing it but it will be of great help if you could do it more efficiently . Anyways i am closing this post thanks again

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Highlight a set of data from column D and remove the same words from Column E

    Sub macro_1()
    Application.ScreenUpdating = False
    Dim count, target_word, pos, i
    count = 1
    Do Until Range("D" & count) = ""
    target_word = Array(Range("B" & count),Range("C" & count))
    For i = 0 To 1
    Range("E" & count) = Trim(Replace(Range("E" & count), target_word(i), ""))
    pos = InStr(1, Range("D" & count), target_word(i))
    If pos > 0 Then
    Range("D" & count).Characters(pos, Len(target_word(i))).Font.Bold = True
    Range("D" & count).Characters(pos, Len(target_word(i))).Font.Underline = True
    End If
    Next
    count = count + 1
    Loop
    Application.ScreenUpdating = True
    End Sub

  8. #8
    Registered User
    Join Date
    06-20-2013
    Location
    hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Highlight a set of data from column D and remove the same words from Column E

    thanks yudlugar for your time. I have a minor issue after running the code. When i have a target_word string twice in column D , its only getting highlighted once . Is there a way to fix it ?

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Highlight a set of data from column D and remove the same words from Column E

    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. How to remove two specific words from each cell in a column
    By pahari75 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-10-2013, 06:29 PM
  2. [SOLVED] Highlight multiple duplicate words in column B?
    By emil9216 in forum Excel General
    Replies: 3
    Last Post: 07-31-2012, 01:55 PM
  3. Replies: 12
    Last Post: 05-05-2012, 03:58 PM
  4. Is it Possible to Delete or Remove Words from a Column?
    By randolph188 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 10-28-2009, 03:48 PM
  5. Replies: 6
    Last Post: 02-21-2009, 08:13 PM

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