Need a UDF to Identify and remove parts of Cell Data from a Range

Please_H

Board Regular
Joined
Apr 16, 2017
Messages
181
Office Version
  1. 2019
Platform
  1. Windows
Hi Good Morning from Sri Lanka,

I have sets of words in cell A1,A2,A3 in Sheet 1

I have a Range which I look to remove from above Cells (plus I will continue to update that Colomn), They are in Sheet 2, Colomn 4 (ex for words are - Trusted User, Call Now, Sale)

Now I need the following to happen:

A1 = ABC Company Trusted User

Result in B1 = ABC Company

A2 = ABC Company Sale

Result in B2 = ABC Company

A3 = JnH Users and Distributors Call Now

Result in B3 = JnH Users and Distributors

Is this possible?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Maybe a macro to modify the strings while still in column "A"

Code:
Sub MM1()
With ActiveSheet.Range("A:A")
.Replace "Trusted", "", xlPart
.Replace "User", "", xlPart
.Replace "Sale", "", xlPart
.Replace "Call", "", xlPart
.Replace "now", "", xlPart
End With
End Sub
 
Upvote 0
Maybe a macro to modify the strings while still in column "A"

Code:
Sub MM1()
With ActiveSheet.Range("A:A")
.Replace "Trusted", "", xlPart
.Replace "User", "", xlPart
.Replace "Sale", "", xlPart
.Replace "Call", "", xlPart
.Replace "now", "", xlPart
End With
End Sub
Bro, Thanks for your effort, but this will have an issue as the Colomn A has many more issues, therefore I requested a UDF to control the Outcome. A macro at this staage could slow down my excel....What about a functions bro, possible?
 
Upvote 0
Maybe this then....originally posted by PGC01

Code:
Function RW(ByVal s As String)
Dim vArray As Variant, vWord As Variant
vArray = Array("Trusted", "User", "Call", "Now", "Sale")
For Each vWord In vArray
    s = Replace(s, vWord, "")
Next vWord
RW = s
End Function

Then use in B1

Code:
=RW(A1)
 
Upvote 0
Maybe this then....originally posted by PGC01

Code:
Function RW(ByVal s As String)
Dim vArray As Variant, vWord As Variant
vArray = Array("Trusted", "User", "Call", "Now", "Sale")
For Each vWord In vArray
    s = Replace(s, vWord, "")
Next vWord
RW = s
End Function

Then use in B1

Code:
=RW(A1)
Dannnnnnnnnnnnnggggg !!!!!!!!!!!!!!! That Worked ! Thanks Mate... You've done a Great favor for me...
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,230
Members
449,303
Latest member
grantrob

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