代码的功能没有错。只是我不太了解的事情。在定义'数据时,我从Cell(1, 1)
开始,这应该是A1对吗?我不希望它从A1开始,我希望它来自A2(因为标题)。为什么我只能在使用Cells(1, 1)
时获得第一行数据AKA A2:A *?不应该是Cells(2, 1)
吗?
Dim rowCount As Integer
Dim columnCount As Integer
Dim mainsht As Worksheet
Set mainsht = Worksheets("DATA")
'So array size will dynamically change with updates
rowCount = mainsht.Range("A1048576").End(xlUp).Row
columnCount = mainsht.Range("XFD1").End(xlToLeft).Column
' load the headers and data to an array '
headers = Cells(1, 1).Resize(1, columnCount).Value
data = Cells(1, 1).Resize(rowCount, columnCount).Value