Vba Vlookup Date Range

redridinghood74

New Member
Joined
Jul 28, 2017
Messages
14
Some code;
Code:
Private Sub DateReminder()
Dim LastRow As Long
Dim yesterdaysDate As Date
Dim AlertDate As Date
Dim dateRange As Range
Dim foundDate As Range
Dim firstName As String
Dim lastName As String
Dim phoneNumber As String
Dim eMail As String
AlertDate = DateSerial(Year(Date), Month(Date), Day(Date - 2))
LastRow = Worksheets("BOOKINGS").Cells(Rows.Count, 1).End(xlUp).Row
Set dateRange = Worksheets("BOOKINGS").Range("H2:H" & LastRow)
For Each foundDate In dateRange
If DateValue(foundDate.Value) = DateValue(AlertDate) Then
firstName = foundDate.offset(0, 2).Value
lastName = foundDate.offset(0, 3).Value
phoneNumber = foundDate.offset(0, 5).Value
eMail = foundDate.offset(0, 6).Value
MsgBox &firstName & vbNewLine &lastName & vbNewLine &phoneNumber & vbNewLine &eMail
End If
Next foundDate
End Sub

(AlertDate) (dateRange)
03/11/17 != 03/11/17

Vba form uses EVALUATE to build dateRange values from comboboxes.

Matching date doesn't match, scratching head alot :(
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Experimenting for the past 5 hours, solved it myself :eeek:
Code:
Private Sub DateReminder2()
Dim LastRow As Long
Dim firstName As String
Dim lastName As String
Dim phoneNumber As String
Dim eMail As String
Dim staff As String
LastRow = Worksheets("BOOKINGS").Cells(Rows.Count, 1).End(xlUp).Row
For Each fcell In Worksheets("BOOKINGS").Range("H2:H" & LastRow)
If fcell = Date + 3 And fcell <> "" Then
With Worksheets("BOOKINGS")
staff = fcell.offset(0, -6).Value
firstName = fcell.offset(0, -5).Value
lastName = fcell.offset(0, -4).Value
phoneNumber = fcell.offset(0, -2).Value
eMail = fcell.offset(0, -1).Value
End With
MsgBox staff & " : " & fcell & vbNewLine & firstName & " " & lastName & vbNewLine & phoneNumber & vbNewLine & eMail, vbOKOnly, "Booking Reminder"
End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top