+ Reply to Thread
Results 1 to 4 of 4

Conditional Formatting based on Formula

  1. #1
    Registered User
    Join Date
    07-03-2015
    Location
    Bangalore, India
    MS-Off Ver
    2013
    Posts
    4

    Conditional Formatting based on Formula

    Hi, I was wondering if I could get hint regarding following part of my code.

    Objective: I have a function that checks if a cell has formula or not. I call it in sub for setting conditional formatting rule. Idea is if anytime user messes with the cell that has formula I throw a red flag (comment) and color code change to indicate that some action was taken. I am stuck at line Formula1:="=""EstFormula(Range(""$" & "J" & "$" & p & "))=False""" where I am setting the conditional format rule. I would appreciate help and probably a better way to do it in case there is one.

    Thanks for help
    Arjun

    Function EstFormula(rng As Range) As Boolean

    EstFormula = 0

    If rng.HasFormula = True Then
    EstFormula = 1
    'do nothing

    Else
    EstFormula = 0
    rng.AddComment
    rng.Comment.Text Text:="Value edited manually"

    End If

    End Function
    Private Sub Cell_format()


    Dim p As Integer

    p = 3

    Do While ActiveSheet.Range("J" & p) <> Empty

    ActiveSheet.Range("J" & p).Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=""EstFormula(Range(""$" & "J" & "$" & p & "))=0"""
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority

    With Selection.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 49407
    .TintAndShade = 0
    End With

    Selection.FormatConditions(1).StopIfTrue = False

    p = p + 1

    Loop
    End Sub

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Conditional Formatting based on Formula

    Please add code tags as per forum rules.

  3. #3
    Registered User
    Join Date
    07-03-2015
    Location
    Bangalore, India
    MS-Off Ver
    2013
    Posts
    4

    Re: Conditional Formatting based on Formula

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-03-2015
    Location
    Bangalore, India
    MS-Off Ver
    2013
    Posts
    4

    Re: Conditional Formatting based on Formula

    Hello Stephan, Is this ok now. I used the # option here. I am sorry if this is not what you were expecting. I don't see the code in same format as I see in VBA.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Formula based conditional formatting
    By vamshi57 in forum Excel General
    Replies: 5
    Last Post: 04-03-2014, 07:01 AM
  2. [SOLVED] Help with Conditional Formatting Based on Formula
    By rosboy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-27-2013, 12:29 PM
  3. [SOLVED] Conditional Formatting based on a Formula
    By bbyrne in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-01-2012, 08:47 PM
  4. Conditional formatting based on formula
    By Alan35 in forum Excel General
    Replies: 3
    Last Post: 08-22-2011, 08:15 PM
  5. Conditional Formatting based on Now formula
    By Aelestra07 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-20-2010, 03:10 PM
  6. [SOLVED] Conditional formula based on formatting
    By RD in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-27-2006, 01:55 PM
  7. [SOLVED] Conditional Formatting - Formula based
    By Nick Danger in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-10-2005, 02:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1