更改列中日期范围的日期
我对 vba 很陌生,我需要根据条件更改一系列日期的日期(直到列的最后一行)。 例如,在 A 列中,我有一个巨大的日期列表,在 BI 列中有供应商的名称,我需要根据供应商的名称修改新列 (C) 中的日期。如果供应商名称是 A,则将日期更改为 25。
我有此代码,它适用于一行,我需要它用于所有列。
Sub testdata()
Dim date1 As Date
date1 = [a2]
m1 = Month(date1)
d1 = Day(date1)
y1 = Year(date1)
testdate = DateSerial(y1, m1, 25)
Range("c2").Value = testdate
End Sub
有人可以帮我解决这个问题吗?
非常感谢
I'm quite new in vba and I would need to change the day of a range of dates (until last row of the column) based on condition.
For example, in column A i have a huge list of dates, in column B I have the name of the supplier, and I need to modify the date in a new colum (C) based on the name of the supplier. If supplier name is A, then change the day of the date to 25.
I have this code and it works for one line, I would need it for all the column.
Sub testdata()
Dim date1 As Date
date1 = [a2]
m1 = Month(date1)
d1 = Day(date1)
y1 = Year(date1)
testdate = DateSerial(y1, m1, 25)
Range("c2").Value = testdate
End Sub
Anyone could help me with this?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论