ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to change font (https://www.excelbanter.com/excel-programming/397528-macro-change-font.html)

[email protected]

Macro to change font
 
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


Dave Peterson

Macro to change font
 
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.



wrote:

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


--

Dave Peterson

Dave Peterson

Macro to change font
 
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.

wrote:

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


--

Dave Peterson

[email protected]

Macro to change font
 
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



All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com