简体   繁体   中英

VBA prefill worksheet in Excel

I'm need to create a macro (by recording that will pre-fill the spreadsheet with years in column A) so that in the cell A1 we obtain 1950, in A2 1951 and so on and so forth, until 2014. How can I do it?

Please, try the next code. It fills an array with the result of rows range evaluation:

Sub YearsOnAACol()
   Dim arrY
   arrY = Evaluate("row(1950:2014)")
   Range("A6").Resize(UBound(arrY), 1).Value = arrY
End Sub

There are more other ways, but you must search on internet and find solutions by yourself.

I made an exception, only because you are a beginner. Please, learn that next time nobody will answer a question not proving anything about your personal contribution of solving the problem...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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