简体   繁体   English

将Excel日期范围与星期几匹配

[英]Match Excel Date Range with Day of Week

I have a expense form with a departure and return date. 我有一个费用表,上面有出发和返回的日期。 I would like to match all dates between the departure date and return, inclusive, to the day of the week and then populate that date under the appropriate day of the week that exists in another part of the form. 我想将出发日期和返回日期(包括首尾两天)之间的所有日期匹配到星期几,然后将该日期填充在表单另一部分中存在的星期几的适当日期下。 I've provided an example screenshot of what I'm trying to populate and what I'd like it to look like. 我提供了一个示例屏幕快照,其中显示了我要填充的内容以及想要的外观。

I've tried index/match, creating tables to allow the "in between" dates to expand automatically, linking to a date table in powerpivot, etc. and keep failing. 我尝试过索引/匹配,创建表以允许“中间”日期自动扩展,链接到powerpivot中的日期表,等等,并且一直失败。 I haven't tried an VBA yet. 我还没有尝试过VBA。

Your thoughts are much appreciated! 非常感谢您的想法!

例

There's plenty of ways to do this. 有很多方法可以做到这一点。 Along similar lines to what you have tried, I got this. 与您尝试过的类似,我明白了。 It works as per your screenshot and also tested with different dates below: 它可以按照您的屏幕截图运行,并在以下不同日期进行了测试:

在此处输入图片说明


Formulas . 公式

E1: =B1 E1: =B1
E2: =E1+1 and drag down E2: =E1+1并向下拖动
F1: =IF(E1<=$B$2,TEXT(E1,"ddd"),"") and drag down F1: =IF(E1<=$B$2,TEXT(E1,"ddd"),"")并向下拖动
B12: =IFERROR(INDEX($E$1:$E$7,MATCH(B11,$F$1:$F$7,0)),"") and drag across B12: =IFERROR(INDEX($E$1:$E$7,MATCH(B11,$F$1:$F$7,0)),"")并拖移

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM