+ Reply to Thread
Results 1 to 5 of 5

script to replace 3 fonts in multiple Excel SS's.

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2009
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2002/XP
    Posts
    2

    script to replace 3 fonts in multiple Excel SS's.

    Our company has been using 3 fonts company wide for years that were owned by our parent company. Now that we have been sold we must discontinue the use of those fonts in all existing and future Office files. I've created a template in Word to remove these fonts but I am not sure about how to go about it in Excel. The three fonts that need removed are: "Tech Sans Black" "Tech Sans Medium" and "Tech Sans Book" and I can replace these with the Arial font. Any suggestions and help will be appreciated. I will be providing users with a macro that they can run against any spreadsheets that contain these fonts.
    Last edited by VBA Noob; 03-16-2009 at 03:44 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: script to replace 3 fonts in multiple Excel SS's.

    simple macro to change font to arial in all sheets is
    Sub changefont()
    Worksheets.Select
        With Selection.Font
            .Name = "Arial"
            .Size = 10 'change to size you want or leave out
             End With
    End Sub
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    03-16-2009
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2002/XP
    Posts
    2

    Re: script to replace 3 fonts in multiple Excel SS's.

    Thanks for the response. One more question. These are for the most part large multi font spreadsheets. I only want to replace the fonts for the 3 fonts "Tech Sans Book" "Tech Sans Black" and "Tech Sans Medium" How do I specify replacing only those three fonts in the macro?

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: script to replace 3 fonts in multiple Excel SS's.

    Martin was on the right track. You just need to include a few if statements to query for specific font types.

    The code below is a sample that can be modified. It changes any ARIAL fonts to Times New Roman

    Sub Change_Fonts()
        Dim cel As Range
        Dim rng As Range
        
        Set rng = ActiveSheet.UsedRange
        With Application
            .ScreenUpdating = False
            
        For Each cel In rng
            If cel.Font.Name = "Arial" Then
                cel.Font.Name = "Times New Roman"
            End If
        Next cel
        
            .ScreenUpdating = True
        End With
        
    End Sub

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: script to replace 3 fonts in multiple Excel SS's.

    ok i took bigbas's code had a think and reworked it thus
    Sub Change_Fonts()
    Application.ScreenUpdating = False
        Dim cel As Range
        Dim rng As Range
        Dim ws As Worksheet
        For Each ws In ActiveWorkbook.Worksheets
      
             
        Set rng = ws.UsedRange
       For Each cel In rng
        Select Case True
        Case cel.Font.Name = "Times New Roman CE"
                cel.Font.Name = "Arial"
        Case cel.Font.Name = "Times New Roman Greek"
                cel.Font.Name = "Arial"
        Case cel.Font.Name = "Times New Roman TUR"
                cel.Font.Name = "Arial"
        
         End Select
        Next cel
      Next ws
        Application.ScreenUpdating = True
    End Sub
    change font names to suit
    i think this works ok i tested it and it works for me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1