本文为《别怕,Excel VBA其实特别简单(第3版)》随书问题参考答案
参考代码:
Sub 在未打开的工作簿中输入数据()
Dim Irow As Integer, arr As Variant
Workbooks.Open (ThisWorkbook.Path & "\花名册.xlsx")
With ActiveWorkbook.Worksheets(1)
Irow = .Range("A1048576").End(xlUp).Offset(1, 0).Row
arr = Array(Irow - 1, "范丽丽", "女", #8/27/1990#, #5/9/2015#)
.Cells(Irow, 1).Resize(1, 5).Value = arr
End With
ActiveWorkbook.Close savechanges:=True
End Sub
注意,在VBA中,日期数据应写在一对#号之间才能被识别为日期,如代码中的#8/27/1990#