+ Reply to Thread
Results 1 to 2 of 2

Thread: Amendment to macro so that it loops (comparison of dates)

  1. #1
    Registered User
    Join Date
    03-17-2010
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    8

    Amendment to macro so that it loops (comparison of dates)

    Hi all,

    I have a small issue i am sure one of you will solve extremely quickly.

    In each row in column A I have a start date and in each row in column B I have an end date (no set number of rows). What I want is for the list of dates between these 2 dates to be listed in the corresponding cell in column C.

    I have code to do row 1 which works perfectly (see below) but this does not loop ( I want it to loop until it reaches a blank cell).

    Sub WriteDates()
    Dim sc As Range
    
    sd = Range("A1")  ' start date
    ed = Range("B1")  ' end date
    Set sc = Range("C1")  ' start cell
    
    ' check dates
    
    If ed - sd <= 0 Then Exit Sub
    j = 0
    For i = sd To ed
       sc.Offset(j, 0) = i
       j = j + 1
    Next i
    
    End Sub
    Your help would be hugely appreciated.

    Many thanks, matt

  2. #2
    Registered User
    Join Date
    03-17-2010
    Location
    uk
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Amendment to macro so that it loops (comparison of dates)

    sorry mods please delete this. realise i posted it in wrong section. 1st timer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0