Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 20,673 times

Related Categories

Make cells bold using criteria

Neil Derek

In column "A" put a "1" in cells 1 to 27. Put "2" in A28. Put any text in columns B & C 1 to 28. The macro will turn the cells at row 28 Bold. (By changing the position of 2, or adding additional 2's to column A, the other rows will also be made bold)

Sub TestMac()
   Dim c As Object
   
   For Each c In Range("a1:a28")
       If c.Value = 2 Then
           c.Offset(0, 1).Font.Bold = True
           c.Offset(0, 2).Font.Bold = True
       Else
           c.Offset(0, 1).Font.Bold = False
           c.Offset(0, 2).Font.Bold = False
       End If
   Next
End Sub

Comments

  • Excel VBA

    Posted by dyerstm on 04 Sep 2003

    I'm having trouble trying do condition formatting based on a criteria that if the value in a range of cells is greater than the value in another value, make the colour red for example. Here is code I...

  • Alternative

    Posted by antrat on 01 Mar 2002

    Or use Conditional formatting!

    Or if it must be VBA, why not

    Sub TestMac()
    Dim c As Range

    For Each c In Range("a1:a28")
    c.Range("A1:B1").Font.Bold = c = 2
    Next
    End Sub ...