Macro to change font

M

minditservices

I need a macro that changes fonts in an excel document from:

Goudy Old Style to Garamond
-and-
Avenir 45 Book to Gill Sans MT
-and-
Times New Roman to Garamond

If there are other fonts in the document I want to leave them as is.
I
am only concerned with the above 2 fonts.

I have a ton of documents to do which is why I want a macro for it.

Thanks in advance for your help.

Eli
 
D

Dave Peterson

If you're using xl2002+, you can use Edit|Replace and click the options button
and change formats.

If you're using xl2k and below, you'll have to loop through all the cells in the
usedrange.

And if you actually use character by character formatting, you'll have to loop
through each cell and loop through each character.
 
D

Dave Peterson

ps. If you are using xl2002+, try recording a macro when you do it and you'll
have the code.

Rerun that macro for all the worksheets/workbooks you want to modify.
 
M

minditservices

Thanks Dave for pointing me in the right direction. For anyone reading
this in the future here is the code that Excel 2003 generated with the
macro recorder. So change the font names to the ones you want to use.

Sub Macro1()
'
' Macro1 Macro
'

'
With Application.FindFormat.Font
.Name = "Times New Roman"
.Subscript = False
End With
With Application.ReplaceFormat.Font
.Name = "Garamond"
.Subscript = False
End With
Cells.Replace What:="", Replacement:="", LookAt:=xlPart,
SearchOrder:= _
xlByRows, MatchCase:=False, SearchFormat:=True,
ReplaceFormat:=True
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