Results 1 to 9 of 9

Thread: changing cells based on dates

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    BoardCoder
    Licensed Coder
    VBAX Expert mark007's Avatar
    Joined
    May 2004
    Location
    Leeds, UK
    Posts
    620
    Location
    You could just use a worksheet formula to check. Using VBA though I don't see a problem with your code other than the extra end if. You could make it check both columns in one loop though using:

    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 
        If Range("N" & MY_ROWS).Value > Range("H" & MY_ROWS).Value Then 
            MY_CHOICE = MsgBox("date error found in column N/H") 
        End If 
    Next MY_ROWS 
    End Sub
    Last edited by Aussiebear; 04-29-2023 at 09:45 PM. Reason: Adjusted the code tags
    "Computers are useless. They can only give you answers." - Pablo Picasso
    Mark Rowlinson FIA | The Code Net

Posting Permissions

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