Results 1 to 9 of 9

Thread: changing cells based on dates

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Jul 2004
    Posts
    16
    Location

    changing cells based on dates

    I have 3 probabilities and associated dates in columns H,K,N. The following rules should take place - If a cell in column H is 2005, a date in a cell in column K should be greater than column H and following on N should be greater than K (and H) .e.g

    2005 2006 2007 = correct
    2005 2002 2008 = incorrect
    2005 2006 2006 = incorrect

    How would I write a macro to be able to execute a pop up box if this rule hasnt been followed. I use data validation in these columns by making a custom list i dont know if this helps. I thought it would be easier to create 2 VBA codes - 1 to compare columns K and H and one to compare columns K and N.

    Ive had a go but its not working

    Private Sub worksheet_CHECKdates()
    For MY_ROWS = 2 To Range("H65536").End(xlUp).Row
        If Range("H" & MY_ROWS).Value > Range("K" & MY_ROWS).Value Then
            MY_CHOICE = MsgBox("date error found in column H/K")
        End If
    End If
    Next MY_ROWS
    End Sub
    Any ideas?
    Thanks
    Last edited by Aussiebear; 04-29-2023 at 09:44 PM. Reason: Adjusted the code tags

Posting Permissions

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