Find and Replace - based on font

R

Raina

I would like to code a macro such a way that it searches the specifie
cherecters say "yU" (without quats case sensitive) in whole or part o
a cell and replace it with the given cherecters.

Find :
&K}
font is Punjabi
case sensitive
whole or part of cell

Replace :
yU
Font wingdings
case sensitive
size same as previous.

It should be replaced only if all the above conditions (Find) are me
with.
Find string can be any combinations of english cherecters availabl
directly on the keyboard including special cherecters.
May be one of the experts or Gurus here can show me a way.

This is basically a mapping for a local language from english.
Thanks.
Rain
 
T

Tom Ogilvy

Have you tried turning on the macro recorder and doing it manually? This
might be the easiest. (Edit=>Replace) (macro recorder:
Tools=>Macro=>Record a new macro). Then turn off the macro recorder and
look at the recorded code. You can then make substitutions as appropriate.
 
S

Sharad Naik

Try this:

Sharad

Sub punjabi()

With Worksheets(1).Range("a1:f50") 'set your correct range here.
Set c = .Find("&K}", LookIn:=xlValues, Lookat:=xlPart, MatchCase:=True)
If c Is Nothing Then MsgBox "Hi"
If Not c Is Nothing Then
firstAddress = c.Address
Do
If c.Font.Name Like "Punjabi" Then
y = c.Replace("&K}", "yU", Lookat:=xlPart, MatchCase:=True)
c.Font.Name = "Wingdings"
End If
Set c = .FindNext(c)
Loop While Not (c Is Nothing) And (c.Address <> firstAddress)
End If
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top