输入框日期范围在VBA中? [英] Input box date range in vba?
本文介绍了输入框日期范围在VBA中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个excel文件,在第一列(A)中,我有这样的日期:
I have an excel file and in the first column (A) i have some dates like this:
17/10/2013
18/10/2013
19/10/2013
20/10/2013
21/10/2013
22/10/2013
其他列包含一些数据。我需要创建一个输入框,以将日期范围内的所有内容都包含在内。我的意思是;我单击按钮,它显示出一个弹出窗口,例如:
The other columns contains some datas. I need create an input box that takes everything inside a date range. I mean; i click the button and it shows me a popup like:
insert start date: 17/10/2013 (i can decide the date)
insert end date: 20/10/2013 (i can decide the date)
然后我可以放一个我已经完成的宏。因此,我的宏只读取该范围内的数据。
and then i can put a macro i've done. So my macro read only datas inside that range. Is it possible?
推荐答案
没有特定的日期类型,因此您必须进行一些错误检查。这是一个如何从用户那里获取日期的想法:
There is no specific date type so you'll have to do a bit of error checking. Here is one idea of how to get a date from a user:
Dim dateString As String, TheDate As Date
Dim valid As Boolean: valid = True
Do
dateString = Application.InputBox("Enter A Date: ")
If IsDate(dateString) Then
TheDate = DateValue(dateString)
valid = True
Else
MsgBox "Invalid date"
valid = False
End If
Loop Until valid = True
这篇关于输入框日期范围在VBA中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文