冻结。我正在尝试设置公开声明的范围(dataIrradianceRange
和dataTempRange
),但不断获取对象失败的方法范围错误。谁能告诉我哪里出错了。
Public Sub getData()
'for each loop in data book to find right columns for sites
'each site has two columns in the data book...irradiance and amb temp
For j = 2 To siteCount * 2 Step 2
If dataSheet.Cells(1, j).Value = siteNameArray(i) Then
Set dataIrradianceRange = dataSheet.Range(Cells(5, j), Cells(lastRow, j))
Set dataTempRange = dataSheet.Range(Cells(5, j + 1), Cells(lastRow, j + 1))
Exit For
End If
Next j
End Sub
答案 0 :(得分:1)
尝试全程资格认证
With dataSheet
Set dataIrradianceRange = .Range(.Cells(5, j), .Cells(lastRow, j))
Set dataTempRange = .Range(.Cells(5, j + 1), .Cells(lastRow, j + 1)
End With