VBA Code to delete Keyword

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all, I hope someone can help on this please

I need some VBA to do the following

In Column C2: C9997 I have a description of a part number in each cell
In column D2 & E2 i have Keywords
I want to check the value in D2 & E2 and if they keyword is in C2 then copy the contents of C2, remove only the keyword and paste the answer in F2

Example

C2

This dog wants to go for a walk

D2

dog walk

E2

wants

F2

This to go for a
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try The following on test data before using it on actual data. Let me know if this is what you were looking for

Code:
Sub DeletesKeywords()

Dim NewStr As String
Dim i As Integer
Dim MyArr As Variant
Dim MyRng As Range
Set MyRng = Range("C2:C9997")


For Each oCell In MyRng
    With oCell
        MyArr = Split(.Offset(0, 1).Value & " " & .Offset(0, 2).Value)
        NewStr = .Value
        For i = LBound(MyArr) To UBound(MyArr)
            
            NewStr = Replace(NewStr, MyArr(i), "")
    
        Next i
        .Offset(0, 3).Value = NewStr
    End With


Next oCell
 
Upvote 0

Forum statistics

Threads
1,214,901
Messages
6,122,157
Members
449,068
Latest member
shiz11713

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top