如何分配细胞的范围的范围内变化
问题描述:
我的环境:MS Excel的2013如何分配细胞的范围的范围内变化
我要分配单元的范围与代码我的范围变量低于
Dim strSourceFile As String
Dim wbSource As Workbook
strSourceFile = "D:\csv1.csv"
Set wbSource = Workbooks.Open(strSourceFile)
Set rngY = wbSource.Sheets(1).Range(Cells(2, RefCol), Cells(LastSource, RefCol))
我在最后一排,而得到错误试图将值分配给rngY
。
Run-time error '1004':
Application-defined or object-defined error
答
Cells(2, RefCol)
正在引用活动工作表上的单元格。您必须限定所有范围对象。
例1:
Set rngY = wbSource.Sheets(1).Range(wbSource.Sheets(1).Cells(2, RefCol), wbSource.Sheets(1).Cells(LastSource, RefCol))
例2:
With wbSource.Sheets(1)
Set rngY = .Range(.Cells(2, RefCol), .Cells(LastSource, RefCol))
End With
哇,托马斯,你救了我的命 NNOPP
LOL ...谢谢你的支票! – 2016-07-29 07:45:50