-
Solved: VBA to replace specific alphabets with blanks
Hi All,
I am working in excel in 2010. I need help with the below code.
Out of given range I need to replace few alphabets with blanks. I dont know VBA but i searched and could gather few codes in to 1. But it shows a compile error for text1() variable. Can any help.
Below is my code.
[VBA]
Sub findreplace()
Dim i As String
Dim Default
Dim raypoints() As String
Dim text1() As
String, text2 As String
Default = "A,B,C,D,E,F,G,H"
i = InputBox("Letters to Remove", Default, Default)
text2 = ""
raypoints = Split(i, ",")
For text1 = 0 To UBound(raypoints)
With ActiveSheet.Selection
.Cells.Replace what:=text1, Replacement:=text2, LookAt:=xlPart,
_
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False
End With
Next
text1
End Sub
[/VBA]
Thanks & Regards,
Praveen
-
[vba]Sub findreplace()
Dim i As String, Default, raypoints() As String, text2 As String, t As Integer
Default = "A,B,C,D,E,F,G,H"
i = InputBox("Letters to Remove", Default, Default)
text2 = ""
raypoints = Split(i, ",")
For t = 0 To UBound(raypoints)
With Selection
.Replace what:=raypoints(t), Replacement:=text2, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End With
Next t
End Sub[/vba]
-
Hi patel,
Thanks for the help. The code is working now as per my requirement. Thanks again.!!!!!!!!
Regards,
Praveen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules