|
1、时间赋值问题
1)首先dim time as date(看书本资料说date类型也包括时间)
然后将 time 定义为20分钟 , 理想状态为 time = #0:20#
但是系统自动转为了 time = #12:20:00 AM#
请问如何操作才能得到想要的格式。
2)其实是一类问题,使用了 triptime = InputBox("请输入航程时间")
输入时间 1:20 后 自动变成了 01:20:00 AM
2、自动查找空白行问题
假设A列1-5行都有数据,如何将 dept 数据自动填到A5单元格
谢谢大神们指教!
上代码
Public Sub 时间()
Dim dept As String
Dim dest As String
Dim triptime As Date
Dim taxiotime As Date
Dim taxiitime As Date
Dim holdingtime As Date
Dim time As Date
dept = InputBox("请输入起飞机场")
Cells(1, 1) = dept
dest = InputBox("请输入目的地机场")
Cells(1, 2) = dest
triptime = InputBox("请输入航程时间")
Cells(1, 3) = triptime
If dept = "北京" Or dept = "上海" Or dept = "广州" Then
taxiotime = #12:30:00 AM#
ElseIf dept = "成都" Or dept = "深圳" Or dept = "西安" Then
taxiotime = 20
Else
taxiotime = 10
End If
Cells(1, 4) = taxiotime
If dest = "北京" Or dept = "上海" Or dept = "广州" Then
taxiitime = 30
ElseIf dept = "成都" Or dept = "深圳" Or dept = "西安" Then
taxiitime = 20
Else
taxiitime = 10
End If
Cells(1, 5) = taxiitime
If dest = "北京" Or dept = "上海" Or dept = "广州" Then
holdingtime = 20
Else
taxiitime = 10
End If
Cells(1, 6) = holdingtime
End Sub
|
|