Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Set the underline, color and font name

Sub DemonstrateFontObject()      Dim nColumn As Integer      Dim nRow As Integer      Dim avFonts As Variant       Dim avColors As Variant      avFonts = Array("Tahoma", "Arial", "MS Sans Serif", "Verdana", "Georgia")      avColors = Array(vbRed, vbBlue, vbBlack, vbGreen, vbYellow)      For nRow = 1 To 5          With ThisWorkbook.Worksheets(1).Rows(nRow).Font              .Color = avColors(nRow - 1)              .Name = avFonts(nRow - 1)              If nRow Mod 2 = 0 Then                  .Underline = True              Else                  .Underline = False              End If          End With      Next  End Sub