Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Conditional Formatting of Dates (Multiple Criteria)

  1. #1
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    13
    Last edited by DocAElstein; 04-07-2024 at 12:50 PM.

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Hello msiyab,
    I do not know how to do this with a formula. I think it is possible to do with a formula, but I do not know how to do it.

    Here is VBA way, for
    Quote Originally Posted by msiyab View Post
    Column A = Cheque Date
    Column N = Clearing Date
    I want the Conditional Formatting to highlight Column A if the below criterias are met.
    1. Column N is blank. 2. If current date is 150+ days than the Column A date.
    I need this to know if a cheque is nearing its expiry date (6 months).
    If column N = "" And Today - Column A => 150 Then interior color is yellow

    Alan

    _.______________________

    Before:
    _____ Workbook: CheckCheque.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    1
    12.09.2018
    2
    13.09.2018
    07.02.2019
    3
    12.09.2018
    07.02.2019
    4
    11.09.2018
    07.02.2019
    5
    10.09.2018
    6
    09.09.2018
    07.02.2019
    7
    Worksheet: Tabelle1
    _____ Workbook: CheckCheque.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    1
    =TODAY()-148
    2
    =TODAY()-147
    =TODAY()
    3
    =TODAY()-148
    =TODAY()
    4
    =TODAY()-149
    =TODAY()
    5
    =TODAY()-150
    6
    =TODAY()-151
    =TODAY()
    7
    Worksheet: Tabelle1

    Run routine:
    Code:
     Option Explicit
    Sub ChkChqe() ' http://www.excelfox.com/forum/showthread.php/2301-Conditional-Formatting-of-Dates-(Multiple-Criteria)
    Dim Ws1 As Worksheet
     Set Ws1 = ThisWorkbook.Worksheets.Item(1) ' First tab countiung from the left
    Dim rngA As Range: Set rngA = Ws1.Range("A1:A" & Ws1.UsedRange.Rows.Count & "")
    Dim rngN As Range: Set rngN = Ws1.Range("N1:N" & Ws1.UsedRange.Rows.Count & "")
    Dim arrA() As Variant, arrN() As Variant
     Let arrA() = rngA.Value2: Let arrN() = rngN.Value2
    Dim Nah As Long: Let Nah = Now
    Dim Cnt As Long
        For Cnt = 1 To Ws1.UsedRange.Rows.Count
            If arrN(Cnt, 1) = "" And (Nah - arrA(Cnt, 1)) >= 150 Then rngA.Item(Cnt).Interior.Color = vbYellow
        Next Cnt
    End Sub
    
    
    ' msiyab
    '    Conditional Formatting of Dates (Multiple Criteria)
    '    Hi,
    '
    '    I have an Cheque Book Register in Excel.
    '    Column A = Cheque Date
    '    Column N = Clearing Date
    '
    '    I want the Conditional Formatting to highlight Column A if the below criterias are met.
    '    1. Column N is blank.
    '    2. If current date is 150+ days than the Column A date.
    '
    '    I need this to know if a cheque is nearing its expiry date (6 months).

    After:
    _____ Workbook: CheckCheque.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    1
    12.09.2018
    2
    13.09.2018
    07.02.2019
    3
    12.09.2018
    07.02.2019
    4
    11.09.2018
    07.02.2019
    5
    10.09.2018
    6
    09.09.2018
    07.02.2019
    7
    Worksheet: Tabelle1
    Attached Files Attached Files
    Last edited by DocAElstein; 02-07-2019 at 09:14 PM.

  3. #3
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    13
    Hi,

    Just checked the VBA, and I'm getting an error for this line:

    If arrN(Cnt, 1) = "" And (Nah - arrA(Cnt, 1)) >= 150 Then

    What might be the reason?

  4. #4
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Hi
    _1 What is the error?
    _2 can you upload a small amount of test data where you have the error , ( Change any personal or senstive data )
    Alan

  5. #5
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    13
    Quote Originally Posted by DocAElstein View Post
    Hi
    _1 What is the error?
    Run-time error '13':
    Type mismatch

    Quote Originally Posted by DocAElstein View Post
    _2 can you upload a small amount of test data where you have the error , ( Change any personal or senstive data )
    Alan
    Sorry its a company worksheet, with multiple formula, links, etc.

  6. #6
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Hi
    I expected that it might be that type of error. Such an error is typical when tying to compare dates.
    I cannot help further without some test data.
    I only need column A and column N.
    Can you upload a small sample with just column A and column N. You can delete all other information. I only need to see the two columns of dates.

  7. #7
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    13
    Cheque Book Register.xls

    I have attached a sample workbook

    Please note, I have added a few more columns. So the previous Column N is now Column L in the new file.
    Last edited by msiyab; 02-11-2019 at 12:27 PM.

  8. #8
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Hi msiyab
    Thanks for sample workbook

    To find Where is problem:
    We can look at variables…
    But first
    Attached Images Attached Images
    Last edited by DocAElstein; 02-11-2019 at 04:15 PM.

  9. #9
    Member
    Join Date
    Jun 2012
    Posts
    80
    Rep Power
    13
    Cheque Book Register.xls

    Still does not seem to work. The highlight remains no matter which date i put.

    Am i doing something wrong here?

  10. #10
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10
    Explain again very carefully what you want.
    Give examples to show all scenarios
    What is the current problem ?

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
  •