Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    May 2003
    Posts
    69
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Conditional Formatting (2002)

    Is it possible to use conditional formatting (or another method) to change the row height or font size given certain conditions, such as if A1=True, then change row height or font size to X? Thanks.

    -Troy

  2. #2
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Formatting (2002)

    You could try

    sub RowHt()
    Dim ocell as Range
    For each ocell in Range("A1:A20") ' adjust
    If oCell="True" Then
    oCell.RowHeight = 15
    end if
    Next oCell
    End Sub

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Conditional Formatting (2002)

    Conditional formatting can not change the font size or row height. This would require a macro.

    It could be a standalone macro like Paul posted (run whenever you want) or made more "live and automatic" by adding it to an event. This for example will change the fontsize of cell A1 based on True/False and will be tested anytime that the worksheet is changed (in case A1 is a formula, I tested more than a change in A1). If the row ht is automatic (based on the font, it will increase and decrease as needed.

    <pre>Private Sub Worksheet_Change(ByVal Target As Range)
    With Range("A1")
    If .Value Then
    .Font.Size = 15
    Else
    .Font.Size = 10
    End If
    End With
    End Sub</pre>


    Right-click the sheet name and choose "View code" and add this code to the macro pane that is opened in VB.

    Steve

Posting Permissions

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