Deleting some characters in excel with a macro code

osmanoca

Board Regular
Joined
Apr 16, 2016
Messages
87
hello please help dear helpfull friends
i need a macro code to delete some letters with a code.
for example i want to delete "a, r, ş, ö, ğ, o" in a excel document.
i want a code that i can change letters , they can be less or more than these. so i will write letters that i want to delete and run macro to delele all that letters.

thanks please help
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Since you have some accented characters to replace, then you can do it this way:
Put each the character (both regular & accented character)in separate cells in sheet2 col A starting cell A1.


<tbody>
[TD="class: xl65"][/TD]
[TD="class: xl65, width: 64"]A[/TD]

[TD="class: xl65, align: right"]1[/TD]
[TD="class: xl65"]a[/TD]

[TD="class: xl65, align: right"]2[/TD]
[TD="class: xl65"]r[/TD]

[TD="class: xl65, align: right"]3[/TD]
[TD="class: xl65"]ş[/TD]

[TD="class: xl65, align: right"]4[/TD]
[TD="class: xl65"]ö[/TD]

[TD="class: xl65, align: right"]5[/TD]
[TD="class: xl65"]ğ[/TD]

[TD="class: xl65, align: right"]6[/TD]
[TD="class: xl65"]o[/TD]

</tbody>


Then run this macro (the sheet with the data must be the active sheet):

Code:
[FONT=lucida console][COLOR=Royalblue]Sub[/COLOR] a1087956a()
[I][COLOR=seagreen]'https://www.mrexcel.com/forum/excel-questions/1087956-deleting-some-characters-excel-macro-code.html[/COLOR][/I]
[COLOR=Royalblue]Dim[/COLOR] rng [COLOR=Royalblue]As[/COLOR] Range, r [COLOR=Royalblue]As[/COLOR] Range
[COLOR=Royalblue]With[/COLOR] Sheets([COLOR=brown]"Sheet2"[/COLOR])
[COLOR=Royalblue]Set[/COLOR] rng = .Range([COLOR=brown]"A1"[/COLOR], .Cells(.Rows.count, [COLOR=brown]"A"[/COLOR]).[COLOR=Royalblue]End[/COLOR](xlUp))
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]With[/COLOR]

    [COLOR=Royalblue]For[/COLOR] [COLOR=Royalblue]Each[/COLOR] r [COLOR=Royalblue]In[/COLOR] rng
    Cells.Replace What:=r, Replacement:=[COLOR=brown]""[/COLOR], LookAt:=xlPart, _
         MatchCase:=[COLOR=Royalblue]True[/COLOR], SearchFormat:=[COLOR=Royalblue]False[/COLOR], ReplaceFormat:=[COLOR=Royalblue]False[/COLOR]
    [COLOR=Royalblue]Next[/COLOR]
    
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 
Upvote 0
gW39BFy
dear sir, my document screen image is here. please see it. i want to delete all non arabic letters for example. i want remain only arabic and persian letters.
thanks for help

gW39BFy
here:
https://ibb.co/gW39BFy
 
Last edited:
Upvote 0
Hm, that’s beyond my knowledge.
But if you can have a list of all characters that isn’t Arabic or Persian in your file then just put the list in col A like I described above. It seems your file is a dictionary, what are other language used in it?
 
Upvote 0
it is turkish and persian, so i have to divide them. to divide i have to delete an alphabeth all to remain only one language and then i have to delte other language alphabeth letters to take other language words and i will make to langauges columns. one is turkish and other is persian.
 
Upvote 0
thank you very much dear friend. thanks. no problem i will wait and search for solution.

Sorry, I can’t find with a solution. Maybe someone else here could help.
Or I suggest you get help from another forum that has Word Help section, such as:
http://www.vbaexpress.com/forum/forumdisplay.php?20-Word-Help
because actually Word is better in dealing with words & character, so I believe you get better chance to get a solution.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
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