We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Hi experts,

Here is a task in Excel. In column A, there is a list of trading days. We want to pick out the last day each week in the list and put those days in Column B. For a simple example, in the following list. They are trading days in January 2007.

1/3/2007

1/4/2007

1/5/2007

1/8/2007

1/9/2007

1/10/2007

1/11/2007

1/12/2007

1/16/2007

1/17/2007

1/18/2007

1/19/2007

1/22/2007

1/23/2007

1/24/2007

1/25/2007

1/26/2007

1/29/2007

1/30/2007

1/31/2007

And we want column B as:

1/5/2007

1/12/2007

1/19/2007

1/26/2007

The real data is much larger than one month. Is there a easy way to do it in formula?

Here is a task in Excel. In column A, there is a list of trading days. We want to pick out the last day each week in the list and put those days in Column B. For a simple example, in the following list. They are trading days in January 2007.

1/3/2007

1/4/2007

1/5/2007

1/8/2007

1/9/2007

1/10/2007

1/11/2007

1/12/2007

1/16/2007

1/17/2007

1/18/2007

1/19/2007

1/22/2007

1/23/2007

1/24/2007

1/25/2007

1/26/2007

1/29/2007

1/30/2007

1/31/2007

And we want column B as:

1/5/2007

1/12/2007

1/19/2007

1/26/2007

The real data is much larger than one month. Is there a easy way to do it in formula?

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

see it in attached file

End-of-week-from-Date.xlsx

End-of-week-from-Date.xlsx

If "end of week" means Friday like the examples above, you can get this information from one of two formulas:

=TEXT(A1, "ddd") will return the three character shorthand for the day (e.g. "Fri")

=MOD(A1, 7) will return the remainder when dividing by 7 (e.g. 6, for Friday)

Option 1 is easier to understand; Option 2 is generally faster.

Either of those formulas could be copied down column B and used to filter for the Friday value. If you just want the matching results, you can run a quick VBA through column A using either formula above to print results. If you need updating formulas in column B which only return matching results, it can be done but gets a little fancy. That formula would depend on ranges and be an array formula, but look something like this using the MOD approach above.

=SMALL(IF(MOD(A1:A27,7)=6,

If end of week means the "last day of this week of the dates provided", that can be done, but it gets even fancier.

Reply if those formulas are what you need and what final form is acceptable.

In addition, in Column B, we just want the dates that are the end of week dates. A end of week date for each date from Column A is not what we wanted.

For example, in the January 2007 list, we just want 4 dates in column B.

Thanks for trying.

now this is a new requirement you are asking for.

based on your original question the provided formula =A1+7-(WEEKDAY(A1)+1) does produce the result you have asked.

See the attached file for a solution. This would probably be done much cleaner with VBA if that is acceptable. If not, I think you are stuck with some helper columns. At least, that's the best I can do. You can always copy/paste values and delete the helper columns if that's OK.

Note that I have named the input dates "dates" and my helper column with week numbers "weeks". This cleans up the formulas a bit.

Hopefully you can see how to modify this for your dates. Note this assumes that "offending" dates will not be present in the input. If they are there, then this really cannot be done.

Last-day-of-week-sample.xlsx

Thank you. there is no problem of using helper column. I like your idea of getting the "week number" in column C and D. I wonder if Column D can handle the missing week, such as the following trading dates.

9/4/2001

9/5/2001

9/6/2001

9/7/2001

9/10/2001

9/17/2001

9/18/2001

9/19/2001

9/20/2001

9/21/2001

9/24/2001

9/25/2001

9/26/2001

9/27/2001

9/28/2001

Once we have the week number, then we can get the Friday of that week. Then arrange the original trading date in the ascending order and use vlookup to look for the date closest to the Friday of that week. It should be handle something like the following sequence.

7/1/2008

7/2/2008

7/3/2008

7/7/2008

7/8/2008

7/9/2008

7/10/2008

7/11/2008

7/14/2008

7/15/2008

7/16/2008

7/17/2008

7/18/2008

7/21/2008

7/22/2008

7/23/2008

7/24/2008

7/25/2008

7/28/2008

7/29/2008

7/30/2008

7/31/2008

See that July 4th was a Friday, but was not a trading date. But if we use vlookup to look for all the dates in this list that is approximate to 7/4/2008, it will give us 7/3/2008 and it is the last trading date of that week. Wanna go for it?

Thanks.

7/3/2008

7/11/2008

7/18/2008

7/25/2008

7/31/2008

in column B. I believe this is what you are expecting for output? For the September dates, it spits out:

9/7/2001

9/10/2001

9/21/2001

9/28/2001

which also appears correct.

The main thing now is expanding the formulas so that they cover the full range of inputs that you are expecting. If you paste in the full range of dates for column A, you can then:

* fill columns B, C, and D down to the end of the data (B and D technically only need to go as far as the number of outputs, but you may as well drag them all the way down)

* update the named ranges "dates" and "weeks" to end at the correct row.

If you can make those changes, you are good to go. If not, tell me how many inputs you have, and I will update it. Or, alternatively, I can update the spreadsheet for 1000 or so inputs, and you can batch them in.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialFor example:

=CEILING(TODAY(),7) gives 1 Nov 2014.

=FLOOR(TODAY(),7) gives 25 Oct 2014

If you want to adjust to the Friday then just put -1 on the end.

The syntax for CEILING and FLOOR are:

=CEILING(Number,Factor)

Number - any number

Factor - the multiple to which you want to round.

With dates being stored as numbers and day 1 of the Excel calendar being 1 Jan 1900 which was a Sunday, every Saturday thereafter is a multiple of 7 so rounding up or down to a factor of 7 gives the Saturday date.

Combining this with a MATCH could then check for holidays and deducting a further day to return the Thursday if required.

=CEILING(TODAY(),7)-IF(ISE

Thanks

Rob H

First entry in column B:

=CEILING(MIN(A:A),7)-IF(IS

Further entries in column B, if only one month at a time the most you will need is 5 in total; 1 as above and 4 of the following:

=IF(MONTH(B1+7)<>MONTH(B1)

This will need tweaking to allow for holidays as well so I will take a look at that.

Thanks

Rob H

=CEILING(MIN(A:A),7)-IF(IS

Thanks

Rob H

=IF(WEEKDAY(MIN(A:A))=7,MI

Tweaked subsequent date calculations:

=IF(MONTH(IF(ISERROR(MATCH

See attached, I have deliberately used April as Good Friday was a Holiday.

Thanks

Rob H

Friday-Dates.xlsx

=IF(WEEKDAY(MIN(A:A))=7,MI

Thanks

Rob H

Yes, I tested out your formula and it did give out nice results.

I notice that you use array formula in Column B, and find out the max of of all dates for the given week. that is very clever. it can be better than vlookup in this way

Thank you.

Microsoft Applications

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.