Results 1 to 10 of 20

Thread: Conditional Formatting of Dates (Multiple Criteria)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Hello msiyab,
    Possibly Solution 1: This could be to refresh the range of dates in column A so that initially all the yellow highlighting is cleared.
    ( We do not want to risk changing anything you have in cells A1 and A2, so we can use the Offset( , ) property on the range followed by the Resize( , ) Property to adjust the range dimensions. )
    Code:
    Sub ChkChqe()
    Dim Ws1 As Worksheet
     Set Ws1 = ThisWorkbook.Worksheets.Item(1)
    Dim rngA As Range: Set rngA = Ws1.Range("A1:A" & Ws1.UsedRange.Rows.Count & "")
     Let rngA.Offset(2, 0).Resize(Ws1.UsedRange.Rows.Count - 2, 1).Interior.TintAndShade = 0
    Dim rngL As Range: Set rngL = Ws1.Range("L1:L" & Ws1.UsedRange.Rows.Count & "")
    Dim arrA() As Variant, arrL() As Variant
     Let arrA() = rngA.Value2: Let arrL() = rngL.Value2
    Dim Nah As Long: Let Nah = Now
    Dim Cnt As Long
        For Cnt = 3 To Ws1.UsedRange.Rows.Count
            If arrA(Cnt, 1) = "" Then
            ' Do nothing
            Else
              If arrL(Cnt, 1) = "" And (Nah - arrA(Cnt, 1)) >= 150 Then rngA.Item(Cnt).Interior.Color = vbYellow
            End If
        Next Cnt
    End Sub
    Possibly Solution 2: This would be an advancement and modification to Solution 1: Procedure Sub ChkChqe() from above, could be converted into an “Events type” procedure . This would then run the routine automatically when you changed any value. This would simply save you having to run the procedure yourself.

    Alan
    Last edited by DocAElstein; 02-12-2019 at 06:59 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

  2. #2
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    14
    Quote Originally Posted by DocAElstein View Post
    Hello msiyab,
    Possibly Solution 1: This could be to refresh the range of dates in column A so that initially all the yellow highlighting is cleared.
    ( We do not want to risk changing anything you have in cells A1 and A2, so we can use the Offset( , ) property on the range followed by the Resize( , ) Property to adjust the range dimensions. )
    This solution seems to be working. But I need to run the macro manually to update the conditional formatting every time.


    Quote Originally Posted by DocAElstein View Post
    Possibly Solution 2: This would be an advancement and modification to Solution 1: Procedure Sub ChkChqe() from above, could be converted into an “Events type” procedure . This would then run the routine automatically when you changed any value. This would simply save you having to run the procedure yourself.
    How can we make this file a "Events type" macro so that the macro runs automatically?

Similar Threads

  1. testing BBCode with conditional formatting
    By Admin in forum Test Area
    Replies: 0
    Last Post: 01-20-2016, 08:36 AM
  2. get conditional formatting color of a cell
    By SP69 in forum Excel Help
    Replies: 2
    Last Post: 09-30-2013, 03:08 PM
  3. Conditional formatting
    By mahmoud-lee in forum Excel Help
    Replies: 9
    Last Post: 05-30-2013, 03:00 PM
  4. Conditional Formatting using formula.
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 02-18-2013, 11:33 PM
  5. Conditional Formatting - If/And Formula
    By Katrina in forum Excel Help
    Replies: 4
    Last Post: 11-23-2012, 12:45 AM

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
  •