Compare and Find Date

mhb0825

New Member
Joined
Apr 11, 2011
Messages
7
I have a spreadsheet where A1 contains today's date and columns C1 thru PH129 contains weekly increments (dates) i.e. 04/04/2011, 04/11/2011. I would like compare today's date with those dates and determine which column would be the first date that is greater than today. I would eventually like to automatically "scroll" to this date but for now just want to start with the first question. Thanks for the assistance!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I have a spreadsheet where A1 contains today's date and columns C1 thru PH129 contains weekly increments (dates) i.e. 04/04/2011, 04/11/2011. I would like compare today's date with those dates and determine which column would be the first date that is greater than today. I would eventually like to automatically "scroll" to this date but for now just want to start with the first question. Thanks for the assistance!
Is the date range really C1 thru PH129 or is it actually C1 thru PH1?
 
Upvote 0
Welcome to MrExcel board....

wondering if your meant PH1 instead of PH129
Code:
Sub CompareDates()
    x = Date
    y = Application.Match(CLng(x), Range("A1:PH1")) + 1
    MsgBox "Next nearest date in Column " & y
End Sub
 
Upvote 0
Oops! Yes it is PH1, PH129 is the last cell containing a value in the spreadsheet. Thanks for the help!
 
Upvote 0
Oops! Yes it is PH1, PH129 is the last cell containing a value in the spreadsheet. Thanks for the help!
OK, try this array formula**:

=INDEX(C1:PH1,MATCH(TRUE,C1:PH1>A1,0))

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0
Thank you so much, that works great! I really appreciate your expertise!!This spreadsheet is rather lather and cumbersome for scrolling and viewing contents of columns and will actually extend beyond PH1 as time goes on. Is it possible to, based on the date found, then "go to" the cell that contains the date (would be in C1 to Ph1)? Maybe a button?? Hope this makes sense.
 
Upvote 0
Thank you so much, that works great! I really appreciate your expertise!!This spreadsheet is rather lather and cumbersome for scrolling and viewing contents of columns and will actually extend beyond PH1 as time goes on. Is it possible to, based on the date found, then "go to" the cell that contains the date (would be in C1 to Ph1)? Maybe a button?? Hope this makes sense.
How about a hyperlink?

Enter this array formula** in A2:

=HYPERLINK("#"&ADDRESS(1,MATCH(INDEX(C1:PH1,MATCH(TRUE,C1:PH1>A1,0)),1:1,0)),"Goto Date")

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.

Adjust for the end of range PH1.
 
Upvote 0
Kudos! Works perfectly. Although it's not that difficult to scroll, this will save so much time, as I am in this workbook often. Thanks again. :)
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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