+ Reply to Thread
Results 1 to 2 of 2

Compare dates to ranges of dates

  1. #1
    Registered User
    Join Date
    07-11-2005
    Posts
    6

    Compare dates to ranges of dates

    I'm new to VBA and trying to write a macro/code to compare list of dates to range of dates. In my spreadsheet, Col A shows list of due dates, Col D shows start dates, Col E shows end dates, Col F shows the corresponding week number of inclusive Start Date and End Date, i.e. 1, 2, 3, 4 up to 15 weeks. I want to compare the date on Col A to the Col D (Start date) and Col E (End date) if it matches and within the date range between start and end dates, put the week number on Col B. However, if it does not match to the range date, compare it to the next week range (loop?) until it find the match week range and put the corresponding week number on Col B. Any suggestions will be appreciated.

  2. #2
    Registered User
    Join Date
    07-11-2005
    Posts
    6

    Compare dates from range of dates

    Solution to this post from Nimrod:

    Public Sub GetWeek()
    c = Cells(65536, 1).End(xlUp).Row
    ' The specific Date loop
    For rw = 1 To Cells(65536, 1).End(xlUp).Row
    If IsDate(Cells(rw, 4)) Then
    frmProgress.ProgressBar.Value = (rw / c) * 100
    ' The StartDate-EndDateLoop
    For Rww = 1 To Cells(65536, 12).End(xlUp).Row
    If IsDate(Cells(Rww, 12).Value) Then
    If Cells(rw, 4).Value >= Cells(Rww, 12).Value And _
    Cells(rw, 4).Value <= Cells(Rww, 13).Value Then
    Cells(rw, 8).Value = Cells(Rww, 11).Value
    End If ' between dates

    End If ' is start date
    Next Rww ' next start date

    End If ' is date
    Next rw

    End Sub

+ Reply to Thread

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