简体   繁体   中英

Excel autofill date and time

I have a file looks like

5/1/2016    5/1/2016    0:00    1:00    1:00
5/1/2016    5/1/2016    1:00    2:00    1:00
5/1/2016    5/1/2016    2:00    3:00    1:00
5/1/2016    5/1/2016    3:00    4:00    1:00
5/1/2016    5/1/2016    4:00    5:00    1:00
5/1/2016    5/1/2016    5:00    6:00    1:00
5/1/2016    5/1/2016    6:00    7:00    1:00
5/1/2016    5/1/2016    7:00    8:00    1:00

I want to create a CSV file with such format using autofill till 1/1/2040. Please advise how to proceed.

I am going to present two option to you, the first will be formulas, the second will be dates and formatting cells.

OPTION 1)

in ROW 1 enter your initial value that you want to work with then in row two enter the following formulas:

(Column A)
=IF(C2=0,A1+1,A1)

(Column B)
=IF(D2=0,B1+1,B1)

(Column C)
=TIME(MOD(ROW(A2)-1,24),0,0)

(Column D)
=TIME(MOD(ROW(B2),24),0,0)

(Column E)
1:00

Select row 2 and copy it down to about row 211057

OPTION 2)

In A1 place your starting date and time in the following format DATE space HH:MM:SS. So in your case,

5/1/2016 00:00:00

In B1 use

=A1+Time(1,0,0)

In C1 use

=A1

in D1 use

=B1

in E1 use

01:00

Copy B1:E1 to B2:E2

In A2 use

=B1

Select all of A2:E2 and copy down as required.

Format Column A and B to display date only, Format column C, D, andE to display Time in the format of your choosing. I would use 24 hour clock format HH:MM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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