Results 1 to 12 of 12

VBA to read full dates not just the day

Threaded View

  1. #1
    Registered User
    Join Date
    08-04-2009
    Location
    scotland
    MS-Off Ver
    Excel 2003
    Posts
    19

    Exclamation VBA to read full dates not just the day

    Hi,

    I have a macro which searches for the latest date down a column and across particular rows. Extract of the code is shown below:

    Dim LR As Long, i As Long, Val As String
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
        For i = 2 To LR
            If Cells(i, "B") = "Sentence Process" Then _
                If Cells(i, "D") > Val Then Val = Cells(i, "D")
        Next i
    
    Range("G1") = Val
    The problem is that it keeps returning the highest day not dates, for example say 16/06/09 and 03/07/09 are both in the same results the value which is displaying is 16/06/09.

    I believe this is beacuse 16 is higher than 3, and the code is ignoring the fact that it is a date.

    Any ideas?

    Thanks again all!
    Last edited by pmarsella; 08-05-2009 at 03:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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