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:         
- Insert a new sheet at the end of the tab names and paste the range names starting in cell a1. autofit columns a:b and name the worksheet as range names.
 - My contacts list names - Guide
 - Count names in excel - Guide
 - Monk names wow - Guide
 - How to insert at the rate in laptop - Guide
 - Where is the insert key on a laptop - Guide
 
1 response
                
        
                    TrowaD
    
        
                    Posts
            
                
            2921
                
                            Registration date
            Sunday September 12, 2010
                            Status
            Contributor
                            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 :^(