+ Reply to Thread
Results 1 to 3 of 3

Conditional Formatting Criteria

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-14-2017
    Location
    India
    MS-Off Ver
    2013
    Posts
    128

    Conditional Formatting Criteria

    Hi Experts,

    I have excel sheet with multiple nonblank and blank cells. I need cell color to be highlighted when we enter the value in empty cells. Attached the sample input and manually mocked output in sample file. Please help me on this!!

    Thanks in advance.
    Attached Files Attached Files
    Last edited by Manikandan Arumugam; 06-15-2017 at 02:27 AM.
    Manikandan Arumugam
    Excel Learner

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Conditional Formatting Criteria

    Hi
    if what you are trying to do is to change a cell's fill when you type in a value in that cell if it was previously blank, then I don't think you can do that with conditional formatting as that only relates to current values. You can approximate it with VBA for the sheet you are working in with selection change and worksheet change events, though I must admit I don't like these as they tend to be unstable.

    Try this and see if it works

    right click on the name tab of the sheet you at working in and select View Code, then past this code on the VBA sheet. It should change the colour of every cell changed from blank to a value

    Dim OldVal
    
    Public Sub Worksheet_SelectionChange(ByVal Target As Range)
    OldVal = Target.Value
    End Sub
    
    Public Sub Worksheet_Change(ByVal Target As Range)
    If OldVal = "" And Target <> "" Then Target.Interior.Color = RGB(255, 130, 50)
    End Sub
    Last edited by NickyC; 06-15-2017 at 05:32 AM. Reason: simplify

  3. #3
    Forum Contributor
    Join Date
    05-23-2017
    Location
    Bang, India
    MS-Off Ver
    MS Office 2007
    Posts
    221

    Re: Conditional Formatting Criteria

    Hi ... try this code which also resets to normal cell when you delete the wrongly entered data in cells......... and only when you enter data it colors it yellow.....
    Private Sub Worksheet_Change(ByVal Target As Range)
    Set MyRange = Range("A1:A1000")
        For Each Cell In MyRange
            If Cell.Value < 1 Then
            Cell.Interior.ColorIndex = x1None
            End If
    
            If Cell.Value >= 1 Then
            Cell.Interior.ColorIndex = 6
            End If
        Next
    
    Set MyRange2 = Range("B1:B1000")
        For Each Cell In MyRange2
            If Cell.Value < 1 Then
            Cell.Interior.ColorIndex = x1None
            End If
    
            If Cell.Value >= 1 Then
            Cell.Interior.ColorIndex = 6
            End If
        Next
    
    Set MyRange3 = Range("C1:C1000")
    
         For Each Cell In MyRange3
            If Cell.Value < 1 Then
            Cell.Interior.ColorIndex = x1None
            End If
    
            If Cell.Value >= 1 Then
            Cell.Interior.ColorIndex = 6
            End If
         Next
    
    End Sub

+ 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. [SOLVED] Conditional formatting with two IF criteria
    By Jantrao in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-30-2012, 12:56 PM
  2. Replies: 1
    Last Post: 09-14-2010, 03:45 AM
  3. IF statement using formatting criteria (NOT conditional formatting)
    By chelseasikoebs in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2009, 01:57 AM
  4. Can I set more than three criteria for conditional formatting?
    By River in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. Can I set more than three criteria for conditional formatting?
    By David McRitchie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 AM
  6. [SOLVED] Can I set more than three criteria for conditional formatting?
    By David McRitchie in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 06:05 AM
  7. [SOLVED] Can I set more than three criteria for conditional formatting?
    By River in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  8. [SOLVED] Can I set more than three criteria for conditional formatting?
    By River in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-11-2005, 04:05 AM

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