Consulting

Results 1 to 2 of 2

Thread: Conditional formatting

  1. #1

    Question Conditional formatting

    Hi again,

    The value in any cell in Excel can be of 2 types i.e. either a naked value (i.e. you give some value in the cell and then press enter) or a calculated value (i.e. cell value based on some formula and may have some dependency on values of other cell.)

    I am looking for some formatting rule which will format the cell (e.g. change the size of font, make it underlined etc.) if the underlying value of the cell is a calculated value.

    I also want such formatting rule to be applied throughout my excel Workbook.

    Can someone here help me to create such a formatting rule.

    Thanks for your time.

  2. #2
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    .
    Paste this code in the ThisWorkbook module :

    Option Explicit
    
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Target.HasFormula Then
            Target.Interior.Color = vbRed
        Else
            ' remove background colour entirely (i.e. No Fill)
            Target.Interior.ColorIndex = xlColorIndexNone
        End If
    End Sub
    It checks all cells throughout the workbook for the EQUAL symbol. If the symbol is present, it colors the cell RED.

    You can change the "Target.Interior.ColorIndex = xlColorIndexNone to the commands for formatting the cell.

Tags for this Thread

Posting Permissions

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