Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Special characters problem

Status
Not open for further replies.

philk12

Programmer
Dec 29, 2005
20
US
it worked finally!
But just one thng how do I replace special characters.
Do I have to copy them from xl sheet and paste in my script below..
is there any automated way of removing any special characters?

Thanks




Private Sub Worksheet_Change(ByVal Target As Range)
For x = 0 To 9
Cells.Replace What:=x, Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next x
Cells.Replace What:="&", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="/", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="#", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:="-", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Cells.Replace What:=".", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
End Sub
 
Define "special characters"

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 



Hi,

Whooa! In the Worksheet_Change event? Why there? All kind of recursion unless you turn off EnableEvents.

And what is the variable x shouldn't it be an ARRAY that contains the various special characters you want to replace?
Code:
sub ReplaceSpecialCharacters()
  dim x() as string, i as integer
  x(0) = "!"
  x(1) = "@"
'...

  for i = 0 to ubound(x)
     Cells.Replace What:=x(i), Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
  next
end sub


Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top