我想在另一个单元格更改时更改 Excel 单元格。我的数据来自TFS,返回的日期是长日期( 2018/02/02 12:07:33 AM
) 但是旁边的列需要改成短日期( 2018/02/02
) 随时可以新增行。使用以下工作正常,但一旦添加新行,短日期为空:
=DATE(YEAR(E3);MONTH(E3);DAY(E3))
是否可以在没有 VBA 的情况下做到这一点,如果不是,我将如何使用 VBA 实现这一目标。
|A1 |A2 |
|Long Date |Short Date |
|2018/02/02 12:07:33 AM |2018/02/02 |
来自 TFS 的列表每周都会更改,长日期也可能每天或每周更改。起初长日期将为空,当用户按下特定按钮时,来自 TFS 的查询将更新长日期单元格。
Excel\VBA :所以我所做的是:
'Add smalldate to all items in the items page
Dim LastRow As Integer
Dim RowNumber As String
Dim ColumnNumber As String: ColumnNumber = "F"
Dim FixedVariable As String: FixedVariable = "F3:"
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
RowNumber = ColumnNumber & LastRow
Dim RangeValue As String: RangeValue = FixedVariable + RowNumber
Range(RangeValue).Formula = "=DATE(YEAR(E3),MONTH(E3),DAY(E3))"
很有魅力,我需要使用更好的命名约定!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句