简体   繁体   English

直到最后一行才自动填充

[英]Autofill not populating until last row

I am trying to populate the date and have it populate the column until the last row of data. 我正在尝试填充日期,并让它填充列直到数据的最后一行。 However it doesn't seem to populate to the last line of data and I don't understand why. 但是,它似乎并未填充到数据的最后一行,我也不明白为什么。 What is wrong with my code? 我的代码有什么问题?

Sub updatedate()
lastRow = Range("F" & Rows.Count).End(xlUp).Row
Range("F2:F" & lastRow) = Date
Range("F2:F" & lastRow).Style = "Normal"
Range("F2:F" & lastRow).Value = Format(Date, "yyyymmdd")

End Sub

the date in format yyyymmdd to be updated and populated on each row until last in column F 日期,格式为yyyymmdd,将在每行中更新并填充,直到F列中的最后一个

The problem is on the line 问题就在网上

lastRow = Range("F" & Rows.Count).End(xlUp).Row

If you change "F" to "A" (or any other suitable column) it will work better. 如果将"F"更改为"A" (或任何其他合适的列),它将更好地工作。 The last used cell in the F column is not yet used. F列中最后使用的单元格尚未使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM