Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用VBA为时间格式排列列_Vba_Excel - Fatal编程技术网

使用VBA为时间格式排列列

使用VBA为时间格式排列列,vba,excel,Vba,Excel,是否有一种方法可以实现VBA代码,以将下面的a列排列为如下所示 Year Month Day Time 1998 2 1 0 1998 2 1 3 1998 2 1 6 1998 2 1 9 等等 A= 使用Excel中的年、月、日和小时公式,不需要VBA 在B2中: =Year(A2) 在C2中: =Month(A2) 在D2中: =Day(A2)

是否有一种方法可以实现VBA代码,以将下面的a列排列为如下所示

Year    Month    Day   Time 
1998      2       1     0
1998      2       1     3
1998      2       1     6
1998      2       1     9
等等

A=


使用Excel中的年、月、日和小时公式,不需要VBA

在B2中:

=Year(A2)
在C2中:

=Month(A2)
在D2中:

=Day(A2)
在E2中:

=Hour(A2)

向下拖动

哪些数据是您的输入,哪些数据是您的输出?您是否考虑过只使用内置的日期操作公式而不是vba?
=Hour(A2)