Selecting dates

brjohnson

New Member
Joined
Jun 4, 2011
Messages
48
Hi,

I'm wondering if there is a quick way to select values tied to dates from a list that are X days after the starting date, with X being a variable.

For example: If I start 1/1/2000 and chose X=30 days - is there a formula I can apply to capture the 1/1/2000 value, and then every subsequent 30 day value through present?

Thanks!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Excel Workbook
JK
7DateVariable
801/01/200030
931/01/2000
1001/03/2000
1131/03/2000
1230/04/2000
1330/05/2000
1429/06/2000
1529/07/2000
1628/08/2000
1727/09/2000
Sheet1


You mean like this?
 
Upvote 0
If you want to ensure that it runs only through the current days date (or as near as the increment takes it), then I came up with a combination of formula and macro, only because I couldn't come up with the macro code alone that would produce the desired results.

Assuming you have the headers and start date set up like scottylad2 shows, in any given cell (in my case C1) enter in the formula "=INT((TODAY()-($A$2))/30)" << This cell will need format "General" or "Number"

Then you will want a macro like this:
Code:
Sub Macro1()

    With Sheets("Sheet1")

    '.Range("A3") = .Range("A2") + 30
    Dim i As Integer
    For i = 3 To Range("C1")
        .Range("A" & i) = .Range("A" & (i - 1)) + 30
    Next i
    End With
End Sub
Then you could hide the cell with the formula and voila!
 
Upvote 0
Scotty - thanks for the quick reply.

As a follow up - is there a way to return a certain value if a date falls within a certain range?

For example - if on 1/1/2000 XXX Value is returned and on 2/1/2000 YYY Value is returned...

I want to display XXX for all dates 1/1/2000 - 1/31/2000
and
YYY for 2/1/2000 to 3/1/2000 and so on...

Basically I need a if date is within X days of this date then return the value function.
 
Upvote 0
not entirely sure what your trying to do, can you provide a sample of what you have and what you're trying to achieve? ie your layut and expected result
 
Upvote 0
Sure-

I have two tables. One with a date and corresponding results, longer time period (in this case monthly). And a second table which has each date (daily) and I want the results from the monthly input into the daily.

So:

If we have a longer time period table (in this case monthly):

1/1/2000 : XLB
2/1/2000 : IYR
3/1/2000 : IWM

I want to display those results in the daily table as such:

1/1/2000 : XLB
1/2/2000 : XLB
1/3/2000 : XLB...
1/31/2000 : XLB
2/1/2000 : IYR
2/2/2000 : IYR...
3/1/2000 : IWM

the longer time period values fill in the gaps in the daily time period table.
 
Upvote 0
Not really sure how this will tie in with your original question but maybe this

Excel Workbook
KLMNO
19MonthlyValuesDailyValues
2001/01/2001ABC01/01/2001ABC
2101/02/2001DEF02/01/2001ABC
2201/03/2001GHI03/01/2001ABC
2301/04/2001JKL01/02/2001DEF
2401/05/2001MNO02/02/2001DEF
2501/06/2001PQR03/02/2001DEF
2601/07/2001STU04/02/2001DEF
2701/08/2001VWX01/03/2001GHI
2801/09/2001YZA02/03/2001GHI
2901/10/2001BCD03/03/2001GHI
3001/11/2001EFG04/03/2001GHI
3101/12/2001HIJ05/03/2001GHI
Sheet1


this will match a value where the month is the same, if your crossing into a following year you'll need to make a match on both the month and year. Needs to be entered with ctrl + shift + enter
 
Upvote 0
Thank you again!

I'm actually trying to do the reverse of what you just explained. Start with monthly values and populate daily. I think I've got it figured out aside from two issues - copying these ctrl shift enter cells. How is that done?

And then if you could show how to match the year as well I'd appreciate it.

Thank you so much for your help. I have put probably 10 hours into figuring out what you answered in just a few minutes of your time. SOOO appreciated.
 
Upvote 0
After getting deeper into this it looks like the function won't work for what I'm doing.



Uploaded with ImageShack.us

As I'm advancing thirty days at a time there are situations where I have multiple references in the same month. This appears to cause errors. Any ideas?
 
Upvote 0
I'm not sure what way you're adapting it, hopefully you can adapt this. Now it's looking at both the month and year
Excel Workbook
KLMNO
19MonthlyValuesDailyValues
2001/01/2001ABC01/01/2001ABC
2101/02/2001DEF02/01/2001ABC
2201/03/2001GHI03/01/2001ABC
2301/04/2001JKL01/02/2001DEF
2401/05/2001MNO01/01/2003HIJ
2501/06/2001PQR03/02/2001DEF
2601/07/2001STU04/02/2001DEF
2701/08/2001VWX01/03/2001GHI
2801/09/2001YZA02/03/2001GHI
2901/10/2001BCD03/03/2001GHI
3001/11/2001EFG04/03/2001GHI
3101/01/2003HIJ05/03/2001GHI
Sheet1
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,287
Members
452,902
Latest member
Knuddeluff

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