VBA and special characters

Ezguy4u

Active Member
Joined
Feb 10, 2010
Messages
366
Office Version
  1. 365
Platform
  1. Windows
So my problem is I want to delete those special characters, ▼ ▼ ▼ ▼ ▼ ▼, using a VBA program. I tried using record but as you can see VBA turned those characters into ????. I have tried coping and pasting into a VBA window and no joy. Now I am going to have several lines like in cell A1 but I am showing just one line. And the words after the special characters will change. So the input is cell A1 and the output is cell A5. Any questions, comments or suggestions let me know and thanks for your time.
Arnold

VBA Code:
Sub DeleteSpecial()

    Range("A1").Select
    ActiveCell.FormulaR1C1 = _
        "? ? ? ? ? ?"
    Range("A5").Select
    Cells.Replace What:="? ? ? ? ? ?", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
End Sub



24-05-06 my question.xlsm
A
1▼ ▼ ▼ ▼ ▼ ▼303 Alaska Air Group ALK 45.53 ▲1 3 5 1.55 55- 80 (20- 75%) 10.3 NIL 4.40 NIL 2 3/31◆d.92 d.62 3/31 NIL NIL YES
2
3
4
5303 Alaska Air Group ALK 45.53 ▲1 3 5 1.55 55- 80 (20- 75%) 10.3 NIL 4.40 NIL 2 3/31◆d.92 d.62 3/31 NIL NIL YES
Data1
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try on a test page

VBA Code:
Sub DeleteSpecial()
   Cells.Replace What:=ChrW(9660), Replacement:="", LookAt:=xlPart
End Sub
to see if it picks up the character
 
Upvote 0
Solution
Maybe this with formula.
Excel Formula:
=SUBSTITUTE(A1,"▼","")

Edit: @MARK858
This picked up on my end with formula.
Excel Formula:
=SUBSTITUTE(A1,UNICHAR(9660),"")
 
Last edited:
Upvote 0
Edit: @MARK858
This picked up on my end with formula.
Yes tested it at my end beforehand with formula but wanted the OP to test the VBA to make sure they have the same character set
 
Upvote 0
VBA Code:
Code:
Sub DeleteSpecial()
   Cells.Replace What:=ChrW(9660), Replacement:="", LookAt:=xlPart
End Sub
I suggest to provide a method to get the number "9660". Maybe this:
Book1
AB
19660
29650
39670
Sheet2
Cell Formulas
RangeFormula
B1:B3B1=UNICODE(A1)

then:
VBA Code:
Sub Delete_Special_Char()
  ActiveSheet.Cells.Replace What:=ChrW(9660), Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
  ActiveSheet.Cells.Replace What:=ChrW(9650), Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
  ActiveSheet.Cells.Replace What:=ChrW(9670), Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
 
End Sub
 
Upvote 0
I suggest to provide a method to get the number "9660". Maybe this:
With the OP's original data it would be
Excel Formula:
=UNICODE(LEFT(A1,1))
The OP's question only requests the ▼ removed
 
Upvote 0
Ok Thank you guys for your help. Cubist your suggestion is very helpful but I need it work in a VBA program. Mark858 and Akuini you folks hit the nail right on the head. And while I didn't ask to remove the other special characters, I will be removing other special characters now. All I needed was a little push in the right direction. I will be using unicode for the other special characters. Again thank you all for your time.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

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