Find a date in a range of dates
Solved/Closed
BrianGreen
Posts
1005
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
September 30, 2021
-
Updated on Sep 24, 2019 at 12:00 PM
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 - Oct 2, 2019 at 09:24 AM
BrianGreen Posts 1005 Registration date Saturday January 17, 2015 Status Moderator Last seen September 30, 2021 - Oct 2, 2019 at 09:24 AM
Related:
- Find a date in a range of dates
- Is playsee a dating app - Guide
- Apple airtag range - Guide
- Excel if range of cells contains specific text then return value ✓ - Excel Forum
- Different dates of "end to end encryption message" on blank chat? ✓ - Network Forum
- How to highlight overdue dates in excel ✓ - Excel Forum
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Sep 19, 2019 at 12:29 PM
Sep 19, 2019 at 12:29 PM
Hi BrianGreen,
Can you check if the following code performs as requested (to find the first day of Januari):
When I entered the dates as you described, the range used was C3:T23.
The date format in my country is day-month-year. You might want to change code line 4 to match your date format.
For Februari code I would have to change the 4th code line to mDate = "1-2-" & Range("A1"). But again this will probably be different for you because of a different date format.
Hopefully this helps you out.
Best regards,
Trowa
Can you check if the following code performs as requested (to find the first day of Januari):
Sub RunMe() Dim mDate As Date mDate = "1-1-" & Range("A1") For Each cell In Range("C3:T23") If cell.Value = mDate Then cell.Select Exit Sub End If Next cell End Sub
When I entered the dates as you described, the range used was C3:T23.
The date format in my country is day-month-year. You might want to change code line 4 to match your date format.
For Februari code I would have to change the 4th code line to mDate = "1-2-" & Range("A1"). But again this will probably be different for you because of a different date format.
Hopefully this helps you out.
Best regards,
Trowa
Sep 20, 2019 at 08:56 AM
I would never have got that in a thousand years. Now I just need to figure out how it works to deepen my understanding. Ill scour the net and see what I can find regarding the "& Range()" in the "mDate = "1-2-" & Range("A1")" line (line 4 in your code).
As I cant award you a 100% CCM pay rise I would like to offer you the use of my (virtual) private jet whenever you need to get away from it all. Either that or all the virtual beer you can drink!
Thanks again.
Brian.
Sep 23, 2019 at 11:53 AM
Range("A1") stands for the location on your sheet where you stored the year, so you don't have to change the code next year.
Oct 2, 2019 at 09:24 AM
Funny how I'm getting more of these senior moments :^(