我想創建一個使用Match函數的預算,但我甚至無法達到這一點,因爲我試圖創建的動態範圍返回錯誤:「應用程序定義或對象定義的錯誤」。爲什麼Excel VBA給我一個動態範圍的錯誤?
有問題的範圍是RNG
Sub Material()
Dim wSheet As Worksheet
Dim x, dwIndex, offSet, count, upperLeft, bottomRight, r, wall As Integer
Dim rng As Range
x = 0
For Each wSheet In Worksheets
If wSheet.Name = "Drywall Pricing" Then
dwIndex = wSheet.Index - 1
End If
Next wSheet
For i = 1 To dwIndex
If Sheets(i).Range("K1").Value > 0 Then
count = 9
offSet = 41
r = 27
For wall = 1 To count
offSet = (offSet * wall) - (offSet * 1)
upperLeft = (r + 16) + offSet
bottomRight = (r + 27) + offSet
rng = Sheets(i).Range(Cells(upperLeft, 0), Cells(bottomRight, 1))
Next wall
End If
Next i
End Sub
沒有人有任何線索的變量RNG是不是有效?任何幫助都會令人害怕,因爲這太荒謬了。
在此先感謝!
感謝您的回覆......但使用Set分別返回相同的錯誤 – bschaeffer 2009-09-15 13:50:53