VBA根据日期范围自动返回日期 [英] VBA auto return dates based on date range
本文介绍了VBA根据日期范围自动返回日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码有问题
我在C5
中的名为报价的工作表中有开始日期我在我在C6中的相同工作表
I have a start date in a worksheet called "Quotation" in C5 I have an end date in the same worksheet in C6
然后我希望在其他工作表中显示日期
I then want the dates in-between to be displayed in another worksheet
代码我使用的是:
Sub returnDates()
Dim StartD As Date, EndD As Date
Quotation.StartD = Cells(5, 3)
Quotation.EndD = Cells(6, 3)
For Row = 1 To EndD - StartD
Cells(Row, 4) = StartD + Row - 1
Next Row
End Sub
返回以下错误424对象需要
It returns with the following error 424 object required
任何帮助都将非常赞赏
推荐答案
Sub returnDates()
Dim QuotationStartD As Date, QuotationStartD As Date
QuotationStartD = Cells(5, 3)
QuotationEndD = Cells(6, 3)
For Row = 1 To (QuotationEndD - QuotationStartD)
MsgBox QuotationStartD + Row - 1 ' put your sheet and cells
Next Row
End Sub
这篇关于VBA根据日期范围自动返回日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文