我在以下vba代码的最后一行收到应用程序或对象定义错误。为什么呢?
Dim oRange As Range, a As Range, b As Range, c As Range
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Wb1 As Workbook, WB2 As Workbook
Dim SearchString As String, FoundAt As String
On Error GoTo Whoa
Set Wb1 = Workbooks.Add
Set ws1 = Wb1.Worksheets("Sheet1")
Set c = ws1.Range(B4)
答案 0 :(得分:2)
尝试在字符串中使用引号:)
Set c = ws1.Range("B4")
答案 1 :(得分:0)
B4
被视为类型为variant的未声明变量,值为0 / empty / nullstring。由于没有名称为.Name
(“”)的范围(实际上是vbNullString
),因此这将提高1004:
Set c = ws1.Range(B4)
将字符串B4
限定为字符串:
Set c = ws1.Range("B4")