Removing Special Characters with an "IF" statement

Mattie445

New Member
Joined
Sep 15, 2009
Messages
7
If column B contains "Ref.", then remove all special characters from columns D and Y.


Here is an example of Column B, C D and Y: Any assistance much appreciated!



[TABLE="width: 753"]
<TBODY>[TR]
[TD]Material Number</SPAN>[/TD]
[TD]2nd Mat Number</SPAN>[/TD]
[TD]Description</SPAN>[/TD]
[TD]RTA Description</SPAN>[/TD]
[/TR]
[TR]
[TD]Ref.XXXXXXXXX[/TD]
[TD]XXXXXXXXXXX[/TD]
[TD]NE(tm) "NE-SLIM" Valve Model, 4 1/2 in., 3.75 in. Seal Bore ID-Min, RPT , 5.965 in. Max OD, Equalizing Type, 64.5 in.Approximate Length, 4 1/2-13.50# TSH Blue Box x Pin, '13% CHROME' /410 STAINLESS STEEL/17-4 PH STAINLESS STEEL/NICKEL ALLOY 925/NICKEL ALLOY 718 Matl, 7500 psi Pressure Rating, H2S Service, API 14A/ISO 10432, 1,3s API/ISO Level</SPAN>[/TD]
[TD]NE(tm) Tubing-Retrievable Safety Valve, NE-SLIM Valve Model, 4 1/2 in., 3.75 in. Seal Bore ID-Min, RPT , 5.965 in. Max OD, Equalizing Type, 64.5 in.Approximate Length, 4 1/2-13.50# TSH Blue Box x Pin, 13% CHROME/410 STAINLESS STEEL/17-4 PH STAINLESS STEEL/NICKEL ALLOY 925/NICKEL ALLOY 718 Matl, 7500 psi Pressure Rating, H2S Service, API 14A/ISO 10432, 1,3s API/ISO Level</SPAN>[/TD]
[/TR]
</TBODY><COLGROUP><COL><COL><COL><COL></COLGROUP>[/TABLE]
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Thanks, Rick - I'll try them both this afternoon. Will give a progress report!
@Mattie445,

I just noticed that this forum's message processor chopped off some characters in the Orignals constant (the Const statement) between the less than symbol and the greater than symbol in my previous posting (interpretting them as HTML tags no doubt). Below is the code you should use (if I did it right, all the characters in the Originals constant should show up - Edit Note - Yes, I see they are all there now)...
Code:
Sub ReplacePunctuationSymbols()
  Dim X As Long, Char As String, Rng As Range, Cell As Range, Replacements As Variant
  Const Originals As String = ":""=;@&]}[{#$!%*?\|‘+>®<"
  Replacements = Array(" ", ".", "=", ",", "at", "and", ")", ")", "(", "(", "lb/ft", "USD")
  ReDim Preserve Replacements(1 To Len(Originals))
  Set Rng = Range("C2:D" & Cells(Rows.Count, "D").End(xlUp).Row)
  For X = 1 To Len(Originals)
    Char = Mid(Originals, X, 1)
    If Char Like "[*?]" Then Char = "~" & Char
    Rng.Replace Char, Replacements(X), xlPart
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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