【发布时间】:2013-02-05 04:44:18
【问题描述】:
在 VBA 脚本中,我需要修改日期和时间。即增加或减少一天,根据条件将时间设置为上午 8 点或晚上 8 点。
我这里有相关的代码段-
变量声明-
' To reference the cell having the source date
Dim d As String
' To reference the cell where the modified date is written
Dim destCell As String
' Some cell that contains 1 or 0
Dim somecell As String
'If condition and value assignment
If Range(somecell).Value = 1 Then
Range(destCell).Value = DATE(YEAR(Range(d)),MONTH(Range(d)),DAY(Range(d)-1))+TIME(8,0,0)
问题: 我所做的是减少日期并将时间设置为上午 8 点,条件满足时。我收到语法错误。请帮忙。
【问题讨论】: