Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

Automatically adjust date/time in cell to send e-mails on weekly basis

$
0
0
Hello,

I have a range of cells with dates and times in them (e.g. "21-11-2012 17:00")
These are used as reference for a .deferreddeliverytime function to send e-mails in Oulook.

As I have to send these e-mails on a weekly basis, I'm trying to find a code which adjusts the date/time in the cells, to the same time exactly 1 week later. (But only if the previous date hasn't passed ;)).
There are several e-mails, sent on wed/thu/fri/sat, on varying times.

I came up with this code, but it doesn't work the way I would like. I'm not exactly sure what it does, but it adds multiple days/months. It also changes the time in all cells to the time in the first cell.

Code:

Sub Test_date ()
    Dim SendDate, ThisDate As Date
    ThisDate = Date
    SendDate = cell
    For Each cell In ActiveSheet.Range("H13:H20")
    If ThisDate - SendDate >= 7 Then
        ActiveSheet.Range("H13:H20") = cell.Value + 7
    Else: Exit Sub
    End If
    Next cell
End Sub


Viewing all articles
Browse latest Browse all 50090

Trending Articles