因此,我想对单元格范围进行“更好”的引用,以便不必在整个方法中复制/粘贴它,但以下代码不起作用:
Dim cellRange As Range
' fieldIndex = 1, startRow = 10, lastRow = 20
cellRange = s.Range(Cells(startRow, fieldIndex), Cells(lastRow, fieldIndex))
我错过了什么?我可以以其他方式使用它:
s.Range(Cells(startRow, fieldIndex), Cells(lastRow, fieldIndex)).Value = "bob"