Font (Excel & HTML) and Border (HTML/CSS)

Location: http://www.mvps.org/dmcritchie/excel/font.htm      
Home page: http://www.mvps.org/dmcritchie/excel/excel.htm
[View without Frames]

Default Font (#default)

Tools, Options, General, Standard Font to change default font and size (such as also on the formula bar).  You will get a prompt to restart Excel for change to take effect -- "For your changes to the standard font to take effect, you must quit and then restart Microsoft Excel.".  Appears to affect only the formula bar.

The font used is in the worksheet cells and travels with it.

You can use Book.xlt template for new workbooks, and sheet.xlt template for new worksheets.  The template can be stored in you XLStart directory.
  i.e. C:\Program Files\Microsoft Office\Office\Xlstart

You might also try a search for by entering *.xlt in the "Named" box of the Find Files dialog box.

float:right;
text-align:right;
(example)

Changing the font in Excel with VBA (#changefont)

The following code was posted in a question by Chris James.  A loop is used because macro will be checking
each cell; otherwise, the font could have been changed for an entire range with one instruction.
Application
Background
Bold
Color
Colorindex
Creator
FontStyle
Italic
Name
OutlineFont
Parent
Shadow
Size
Strikethrough
Subscript
Superscript
Underline
F2 Object Browser
Font
  Sub TimesNR()
    Dim c As Range
    For Each c In [A1:C5]
      If c.Font.Name Like "Cour*" Then
         c.Font.Name = "Times New Roman"
      End If
    Next c
  End Sub
See page on colors for help with Excel Colorindex values.
See http://www.mvps.org/dmcritchie/rexx/htm/fonts.htm for help with Webdings and Wingdings font character selections.

Font coding changes:, rng is a single or multi cell range

  rng.Font.Bold = True
  rng.Font.Color = RGB(15,0,0) 'use color index instead
  rng.Font.ColorIndex = 3  'Red  
  rng.Font.Italic = True
  rng.Font.Name = "courier"
  rng.Font.OutlineFont = True
  rng.Font.Size = 30
  rng.Font.Strikethrough = True
  rng.Font.Subscript = True
  rng.Font.Superscript = True
  rng.Font.Underline = True
Example to assign a special wingding character to a cell (single cell range)
  cell.Font.Name = "wingdings 3"
  cell = chr(129)  'filled triangle pointing up

Manually changing font and other places to change font (#manual)

Changing of fonts is frequently done by going through properties.

Also see

Fonts and formatting within a cell and/or words (#within)

Setting Font and formatting within a cell (#setting)

Sub bold_after_is()
  Dim savCalc As Long, savScrnUD As Boolean
  savCalc = Application.Calculation
  savScrnUD = Application.ScreenUpdating
  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
  Dim cell As Range, i As Long
  Dim Rng As Range
  Set Rng = Intersect(Selection, ActiveSheet.UsedRange)
  If Rng Is Nothing Then GoTo done
  For Each cell In Rng
    cell = cell.Value       'convert to constant
    i = InStr(1, cell.Value, " is ", 1) ' 1 for Text (case insensitive)
    If i <> 0 Then
      With cell.Characters(i + 4, Len(cell) - i + 3).Font
        .FontStyle = "Bold"
      End With
   End If
  Next cell
done:
  Application.Calculation = savCalc 'Automatic is -4125, ex Tables -4135
  If savCalc = 2 Then MsgBox "Warning you have MANUAL calculation"
  Application.ScreenUpdating = savScrnUD 'True
End Sub
The following Event macro was used for testing:
 A
9 Employee name is David McRitchie
10 Employee IS David McRitchie
11 Employee name is David McRitchie
Private Sub Worksheet_BeforeDoubleClick(ByVal _ 
    Target As Range, Cancel As Boolean)
  Cancel = True
  Call bold_after_is
End Sub

Determining Font and formatting (#determine)

ExamineActiveCell, Tom Ogilvy (2005-08-26, programming).  If installed can be invoked easily from a doubleclick event macro: colors
Private Sub Worksheet_BeforeDoubleClick(ByVal _
     Target As Range, Cancel As Boolean)
  ExamineActiveCell
End Sub
CharCodeNameFontStyleSize StrikethroughSuperscriptSubscript OutlineFontShadowUnderlineColorIndex Color
T84 ArialBold10 FALSEFALSEFALSEFALSEFALSE -41423#FF0000
h104 ArialBold10 FALSEFALSEFALSEFALSEFALSE -41425#0000FF
i105 ArialBold10 FALSEFALSEFALSEFALSEFALSE -4142-4105#000000
s115 ArialBold10 FALSEFALSEFALSEFALSEFALSE -414250#339966
32Arial Regular10FALSEFALSE FALSEFALSEFALSE-4142-4105 #000000
i105 ArialItalic10 FALSEFALSEFALSEFALSEFALSE -414245#FF9900
s115 ArialItalic10 FALSEFALSEFALSEFALSEFALSE -414245#FF9900
32Arial Regular10FALSEFALSE FALSEFALSEFALSE-4142-4105 #000000
a97 ArialRegular10 FALSEFALSEFALSEFALSEFALSE -4142-4105#000000
32Arial Regular10FALSEFALSE FALSEFALSEFALSE-414250 #339966
t116 ArialRegular10 FALSEFALSEFALSEFALSEFALSE 250#339966
e101 ArialRegular10 FALSEFALSEFALSEFALSEFALSE 250#339966
s115 ArialRegular10 FALSEFALSEFALSEFALSEFALSE 250#339966
t116 ArialRegular10 FALSEFALSEFALSEFALSEFALSE 250#339966
.46 ArialRegular10 FALSEFALSEFALSEFALSEFALSE -414250#339966

Keyboard, Characters, Symbols, and Language (#keyboard)

For any symbol such as a Euro (€) Alt+0128 the digits must be typed on the numeric keypad (even on a laptop), not from the number row.  On a laptop Fn+Alt+0128 (the plus signs are not typed, just means hold these keys down and type the other characters)

Symbols in HTML and in Excel, page has instructions to install the CharMap on your Excel toolbar, and lots of other additional information.

You can use CharMap to type symbols, wingdings, webdings, etc.  In Excel you must match the font yourself using the font drop down box within Excel after copying the character to your cell. You can type any character that exists in any of your fonts.

Besides the CharMap there are shortcuts for language letters, and you can change the keyboard layout through the Control Panel, and set a Hot key to switch between the keyboard layouts.  I'm not messing with mine but if that is what you need that is where you would do it.  You might do a Google search on -- typing German characters
You have what you need you don't have to purchase anything.

Installing Multi-Language support in Windows 2000

Print Font List (#print)

There is nothing builtin to display a list of fonts. 

Option Explicit
Sub FontList()
'William West, William (willwest22@yahoo.com), programming 2001-05-02
'http://groups.google.com/groups?selm=OJz78z50AHA.1976%40tkmsftngp03
Application.ScreenUpdating = False
Dim Fnts
Dim i As Long
Set Fnts = Application.CommandBars("Formatting").Controls(1)
For i = 1 To Fnts.ListCount
    Cells(i, 1) = Fnts.List(i)
    Cells(i, 1).Font.Name = Cells(i, 1).Text
Next i
Application.ScreenUpdating = True
End Sub
The above FontList subroutine, I believe, adequately replaces need for posting by Laurent Longre; and which, I believe it requires a subroutine in C++ of his.

See FontInfo on my Formula.htm#fontinfo page.

ISBOLD User Defined Function   (#isbold)

Here is a User Defined Function, to show up as True the entire cell must be formatted not just part of it.  Posted 2003-02-28.

Have left out Application.Volatile line to save you time.  Will be refreshed when workbook is opened, but you can refresh a single cell with F2 then Enter or the entire sheet with Ctrl+Alt+F9

Function ISBOLD(cell As Range) As Boolean
   If cell.Font.Bold Then ISBOLD = True
End Function
usage returns "True" or "False":
  =ISBOLD(A2)
  =IF(ISBOLD(A2),"Bold","")

Strike Through (#strikethrough)

Function HasStrikethrough(a As Range) As String
  If a.Font.Strikethrough Then HasStrikethrough = vbTrue Else HasStrikethrough = vbFalse
End Function

Excel Options (#options)


System Fonts

See what fonts are installed:  Windows Start, Settings, Control Panel, Font

Install new font to system: ... (needs work done here, including where to get)

Make existing font avalable to Excel: ... (needs work done here)


Rest of page is oriented to HTML and CSS

CSS (Cascading Style Sheets (#css)

The font tag has been deprecated in HTML, and the CSS tag should be used instead.  Note you are looking at braces {...} below, not parens (...)
<STYLE TYPE="text/css">
 .yellow {background-color: #ffff00;}
 .cyan {background-color: #00FFFF;}
 .gray {color: #606060;} 
</STYLE>
</head>
[<SPAN CLASS="yellow">Highlight background</span>]
[<span style="color: red;">(#css)</span>]
[<span style="color: gray;">(#css)</span>]
[<span style="color: lime;">(#css)</span>]

This paragraph uses font attributes of  'arial'  in red and bold with STYLE ...

<P style="color: red; font-family: arial; font-weight: bold">This paragraph uses font attributes of  'arial'  in red and bold with STYLE ...</P>

Examples:

More information:

PRE with Style (#colorstyle)

   <pre style="color:#A52A2A">
   ...code... '#A52A2A  is Brown
   </pre>

More information:

HTML Table borders (#borders)

bordercolor is considered proprietory, is valid in IE.  Mozilla begins to get a 3-D halfway decent at 3. appearance.
 
<table border="1" bordercolor="#FF0000"><tr><td> Example of bordercolor </td></tr></table>

 
<table border="1"><tr><td> Example of bordercolor </td></tr></table>

 
<table border="3" bordercolor="#0000FF"><tr><td> Example of bordercolor </td></tr></table>

 
<table border="5" bordercolor="#0000FF"><tr><td> Example of bordercolor </td></tr></table>
More information on HTML and XL2HTML.

Cssborders (#cssborders)

http://www.tizag.com/cssT/border.php -- CSS Tutorial - Border

<style type="text/css">
.tb_none {border-left-width: 0px; border-top-width: 0px; border-right-width: 0px;
border-bottom-width: 0px; Border_style: hidden; BORDER-COLLAPSE: collapse; }
.tb_L {border-left-width:2px; border-top-width:0px;
border-right-width:0px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_T {border-left-width:0px; border-top-width:2px;
border-right-width:0px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_R {border-left-width:0px; border-top-width:0px;
border-right-width:2px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_B {border-left-width:0px; border-top-width:0px;
border-right-width:0px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_LT {border-left-width:2px; border-top-width:2px;
border-right-width:0px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_LR {border-left-width:2px; border-top-width:0px;
border-right-width:2px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_LB {border-left-width:2px; border-top-width:0px;
border-right-width:0px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_TR {border-left-width:0px; border-top-width:2px;
border-right-width:2px; border-bottom-width:0px; border-style:solid; border-color:black; }
.tb_TB {border-left-width:0px; border-top-width:2px;
border-right-width:0px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_RB {border-left-width:0px; border-top-width:0px;
border-right-width:2px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_LTB {border-left-width:2px; border-top-width:2px;
border-right-width:0px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_LRB {border-left-width:2px; border-top-width:0px;
border-right-width:2px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_TRB {border-left-width:0px; border-top-width:2px;
border-right-width:2px; border-bottom-width:2px; border-style:solid; border-color:black; }
.tb_LTRB {border-left-width:2px; border-top-width:2px;
border-right-width:2px; border-bottom-width:2px; border-style:solid; border-color:black; }
</style>
</head><body>
<!-- increasing cellpadding will make table bigger -->
<!-- ================== Fri 2005-12-30 22:33:52 ============== -->
<table class="tb_none" border="0" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" align="center">

Excel Borders to CSS (#xlborders)

Hope you weren't looking for Gridlines and Borders, or for Colors in Excel. 

The page you are on and particularly this topic applies to HTML and CSS creation through VBA,

 Dim TB As String  'See Excel to HTML (xl2html.htm)  
  TB = ""
  If Target.Borders(xlEdgeLeft).LineStyle <> xlNone Then TB = TB & "L"
  If Target.Borders(xlEdgeTop).LineStyle <> xlNone Then TB = TB & "T"
  If Target.Borders(xlEdgeRight).LineStyle <> xlNone Then TB = TB & "R"
  If Target.Borders(xlEdgeBottom).LineStyle <> xlNone Then TB = TB & "B"
  If TB <> "" Then TB = " Class=""TB_" & TB & """"

Control Panel (#cpanel)

worksheet tab font/size change:  Start>Settings>Control Panel...>Display>Appearance and change the font size for the 'Scrollbar' setting.

Problems (#problems)

More pages with Font information (#more)

References to Site pages directly related to Fonts and Symbols
Symbols for HTML and Excel use
Excel characters as seen in the US (windows-1252)
FONT Table showing the fonts: Arial, Symbols, Webdings, Wingdings, Wingdings 2, Wingdings 3.
References on Font page (this page)
FONT, test for BOLD with ISBOLD(cell) UDF.
References on Formula page there are several.
BoldSum, Sum the cells having Bold format attribute
FontInfo macro on Formula page to get font information. [font information there could possibly be move to this (font.htm) page.]
FontStyle, Display Font Style used in referenced cell
FormulaBox font information for first cell, and general information for all cells in a selection [on formula.htm page]
References on Other pages on this site
Colors includes FONT information where color is involved.
Gridlines and Borders, Display and Printing in Excel
Conditional Formatting can change fonts, font attributes, borders, shading (patterns)
Font information on pages other than font.htm, formula.htm
Pathname page for headers and footers.
bookmarklets, can change fonts, colors, etc in HTML.
Firefox web browser will not see webdings, wingdings, symbol fonts unless you make modifications.  You may have trouble with such fonts in non Windows machines and in non Internet Explorer browsers.
Logos and Graphics into headers/footers, include references to designing logos.
Reference to offsite pages.
CoolText: Logo Generator and Web Design Tool - Online Graphics Generator, online graphics generator for web pages and anywhere else you might need an impressive logo without a lot of work. Logos, Buttons, Fonts, Textures.

External Pages on Fonts   (#external)

Fonts (4 font sites mentioned in LockerGnome 2004-06-04
Font Freak
The Font Foundry
1001 Free Fonts
Font Paradise
Free fonts:
Abstract Fonts - 10,000 Free Fonts for Download, use site search, doesn't look like there would be much difficulty finding fonts here.  There are non-free items on this site, in fact Found NOTHING free on this site, even though they claim to be still recommended at The FreeSite; Also has a macro to see if a font is installed.
Links to Free Font sites,
part of TheFreeSite.com   --Warning hard to find any free fonts.  Also see Related area of Mail Merge for such things as BarCode fonts.
CoolText: Logo Generator and Web Design Tool - Online Graphics Generator, online graphics generator for web pages and anywhere else you might need an impressive logo without a lot of work. Logos, Buttons, Fonts, Textures.
XMAS FONTS.com - Your source for free Christmas typefaces. and other winter fonts.
Fonts & Things - HOLIDAY FONTS
Pay for fonts
Font Searches
Layout
3-column layout, LawLawLaw: Erik J. Heels: Movable Type Brain Dump
Cascading Style Sheets (CSS) in HTML (offsite)
Roxen Community: RFC 1345 Character Mnemonics & Character Sets ()
Font vs. CSS in HTML,   the use of Font in HTML has be deprecated. 
  (Overview of Fonts and Font Families).
Web Design Insights: Advanced: CSS: Intro to CSS -- Text Effects
CSS3: Multi-column Demo for Firefox
Fonts, Getting a List of Installed Fonts (tip 79) -- John Walkenbach (tip 79)
A simple technique (for Excel 97 or later) to retrieve a list of installed font names, and an alternative to an API function on Stephen Bullen's site for those who don't have XL97.  modification to show a string in different fonts. 
FontList (bitstorm.org) «, Use FontList to view all installed fonts in your web browser using text of your choice.  (/\)
The Font Thing -- Sue Fisher [update notes], thanks to Jim Rech (2000-03-15) for telling us.
Provides information on installed and uninstalled fonts, font samples for your text, including use of two fonts in samples.
Excel Tip : Display all installed fonts (Excel) using VBA in Microsoft Excel / Microsoft Excel Tips from Excel Tip .com
Microsoft Typography - Free font information, TrueType, OpenType, ClearType
Font comparisons
Typetester Compare fonts for the screen, Marko Dugonjic

Related -- syntax (#syntax)

If not familiar with installation and use of macros, see Getting Started with Macros and User Defined Functions

Related -- Microsoft KB articles   (#mskb


You are one of many distinguished visitors who have visited my site here or in a previous location  since this page was created on January 26, 2001. 

Visit [my Excel home page]   [Index page]   [Excel Onsite Search]   [top of this page]

Please send your comments concerning this web page to: David McRitchie send email comments


Copyright © 1997 - 2006,  F. David McRitchie,  All Rights Reserved