填补 Excel 中的时间空白
Filling in time gaps in Excel
我在 excel sheet 中有以下内容:
start end value
1 26/11/2014 13:00 26/11/2014 20:00 decreasing
2 26/11/2014 20:00 27/11/2014 09:00 increasing
我想将上面的table转成一个table,其中每行时间都打开并用value
填充。时间间隔从start
时间到end
时间补上-1,如下:
date hour value
1 26/11/2014 13:00 decreasing
2 26/11/2014 14:00 decreasing
3 26/11/2014 15:00 decreasing
4 26/11/2014 16:00 decreasing
5 26/11/2014 17:00 decreasing
6 26/11/2014 18:00 decreasing
7 26/11/2014 19:00 decreasing
8 26/11/2014 20:00 increasing
9 26/11/2014 21:00 increasing
10 26/11/2014 22:00 increasing
11 26/11/2014 23:00 increasing
12 26/11/2014 00:00 increasing
13 26/11/2014 01:00 increasing
14 26/11/2014 02:00 increasing
15 26/11/2014 03:00 increasing
16 26/11/2014 04:00 increasing
17 26/11/2014 05:00 increasing
18 26/11/2014 06:00 increasing
19 26/11/2014 07:00 increasing
20 26/11/2014 08:00 increasing
假设这是您的原始数据的位置:
B2 ---> 26/11/2014 13:00
B3 ---> 26/11/2014 20:00
C2 ---> 26/11/2014 20:00
C3 ---> 27/11/2014 09:00
D2 ---> decreasing
D3 ---> increasing
然后在 sheet2 中,放置一些标签:
B1 ---> date
C1 ---> hour
D1 ---> value
一些日期生成器..假设 Sheet1!B2 是开始日期..
B2 ---> =DATE(YEAR(Sheet1!B2),MONTH(Sheet1!B2),DAY(Sheet1!B2))
C2 ---> =TIME(HOUR(Sheet1!B2),MINUTE(Sheet1!B2),SECOND(Sheet1!B2))
B3 ---> =IF(INT((C2+TIME(1,0,0)))>INT(C2),B2+1,B2)
C3 ---> =IF((TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))>1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0)-1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))
最后,使用 Sheet1!C3 作为结束日期,定义输出。
D2 ---> =IF((B2+IF(C2=1,0,C2))<Sheet1!$C,IF((B2+IF(C2=1,0,C2))<Sheet1!$C,Sheet1!$D,Sheet1!$D),"")
拖到 E21。完成。
希望对您有所帮助。如果公式中有任何您无法理解的部分,请给我留言。 ( :
我在 excel sheet 中有以下内容:
start end value
1 26/11/2014 13:00 26/11/2014 20:00 decreasing
2 26/11/2014 20:00 27/11/2014 09:00 increasing
我想将上面的table转成一个table,其中每行时间都打开并用value
填充。时间间隔从start
时间到end
时间补上-1,如下:
date hour value
1 26/11/2014 13:00 decreasing
2 26/11/2014 14:00 decreasing
3 26/11/2014 15:00 decreasing
4 26/11/2014 16:00 decreasing
5 26/11/2014 17:00 decreasing
6 26/11/2014 18:00 decreasing
7 26/11/2014 19:00 decreasing
8 26/11/2014 20:00 increasing
9 26/11/2014 21:00 increasing
10 26/11/2014 22:00 increasing
11 26/11/2014 23:00 increasing
12 26/11/2014 00:00 increasing
13 26/11/2014 01:00 increasing
14 26/11/2014 02:00 increasing
15 26/11/2014 03:00 increasing
16 26/11/2014 04:00 increasing
17 26/11/2014 05:00 increasing
18 26/11/2014 06:00 increasing
19 26/11/2014 07:00 increasing
20 26/11/2014 08:00 increasing
假设这是您的原始数据的位置:
B2 ---> 26/11/2014 13:00
B3 ---> 26/11/2014 20:00
C2 ---> 26/11/2014 20:00
C3 ---> 27/11/2014 09:00
D2 ---> decreasing
D3 ---> increasing
然后在 sheet2 中,放置一些标签:
B1 ---> date
C1 ---> hour
D1 ---> value
一些日期生成器..假设 Sheet1!B2 是开始日期..
B2 ---> =DATE(YEAR(Sheet1!B2),MONTH(Sheet1!B2),DAY(Sheet1!B2))
C2 ---> =TIME(HOUR(Sheet1!B2),MINUTE(Sheet1!B2),SECOND(Sheet1!B2))
B3 ---> =IF(INT((C2+TIME(1,0,0)))>INT(C2),B2+1,B2)
C3 ---> =IF((TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))>1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0)-1,TIME(HOUR(C2),MINUTE(C2),SECOND(C2))+TIME(1,0,0))
最后,使用 Sheet1!C3 作为结束日期,定义输出。
D2 ---> =IF((B2+IF(C2=1,0,C2))<Sheet1!$C,IF((B2+IF(C2=1,0,C2))<Sheet1!$C,Sheet1!$D,Sheet1!$D),"")
拖到 E21。完成。
希望对您有所帮助。如果公式中有任何您无法理解的部分,请给我留言。 ( :