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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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.

A
1a
2r
3ş
4ö
5ğ
6o

<tbody>
</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,214,409
Messages
6,119,339
Members
448,888
Latest member
Arle8907

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