|
-
Jan 24th, 2011, 04:38 PM
#1
Thread Starter
Junior Member
[Excel] Lookup a value using a date range
I have the following challenge:
I have a table containing date ranges for weeks, and a week code telling me if this is an A week, a B week, or a C week, like this:
WeekCode FromDate ToDate
A 1/30/2011 2/5/2011
B 2/6/2011 2/12/2011
C 2/13/2011 2/19/2011
D 2/20/2011 2/26/2011
A 2/27/2011 3/5/2011
B 3/6/2011 3/12/2011
C 3/13/2011 3/19/2011
D 3/20/2011 3/26/2011
The user enters in two dates here:
Fromdate= 2/1/2011
ToDate = 2/28/2011
I need the following to be populated:
A WEEK ENDS ON: datethatislookedup
B WEEK ENDS ON: datethatislookedup
C WEEK ENDS ON: datethatislookedup
D WEEK ENDS ON: datethatislookedup
I need to know the formulas that go in the "datethatislookedup" cells
The table of dates I have is for the entire year and is in order.
-
Jan 25th, 2011, 06:50 AM
#2
Re: [Excel] Lookup a value using a date range
as you have multiple weeks of each letter how do we know which A week you want the end date of
what are the input dates for?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 25th, 2011, 09:03 AM
#3
Re: [Excel] Lookup a value using a date range
Also where are you getting the dates from? A table in a database? A spreadsheet?
You never specify what datethatislookedup is supposed to do. Find a ToDate that is within a week? Do something with the Fromdate? Or not?
If you want a formula you need to describe clearly and in detail what you need. You know what you want it to do, but unless you explain what you want completely, no one can help you.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Jan 25th, 2011, 09:25 AM
#4
Thread Starter
Junior Member
Re: [Excel] Lookup a value using a date range
The list of dates is in the same sheet and starts at the beginning of the year and go to the end.
The user will enter the from and to dates of the current month. Once they do that, the "datethatislookedup" formula will look between those two entered dates (from and to for the month) and display the week ending date of the A week, the B week,etc.
-
Jan 25th, 2011, 09:51 AM
#5
Re: [Excel] Lookup a value using a date range
Try this:
Code:
=IF(C3 < C1, "Week", "")
Where C1 is the ToDate and C3 is the cell with the week ending date. From your example, it would be 2/5/2011.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|