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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,575
Office Version
  1. 365
Platform
  1. Windows
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]
 

osmanoca

Board Regular
Joined
Apr 16, 2016
Messages
87
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

here:
https://ibb.co/gW39BFy
 
Last edited:

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,575
Office Version
  1. 365
Platform
  1. Windows
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?
 

osmanoca

Board Regular
Joined
Apr 16, 2016
Messages
87

ADVERTISEMENT

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.
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,575
Office Version
  1. 365
Platform
  1. Windows
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.
 

osmanoca

Board Regular
Joined
Apr 16, 2016
Messages
87
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,518
Messages
5,529,309
Members
409,862
Latest member
lbisacca
Top