1
發生故障的線路,通過‘設置X =’方法「對象範圍」 _Worksheet」失敗 - 但如果我叫子從另一個子
這可能是大的線索開始:當我運行這個代碼作爲一個單獨的子,它運行良好。我只從的另一個子中調用此子時出錯。爲什麼會這樣呢?
Option Explicit
Sub EIRPChartUpdate()
'update EIRP Chart
Application.ScreenUpdating = False
Dim x As Range, y1 As Range, y2 As Range, y3 As Range, y4 As Range
Dim points As Long
Set EIRPChart = Sheets("EIRP Chart")
Set EIRPSummary = Sheets("EIRP Summary")
'get last row of EIRP Summary
lastEIRPSummaryRow = EIRPSummary.Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
'count the number of data points
points = lastEIRPSummaryRow - [ESDataRow1].Row + 1
'set independent and dependent data ranges
With EIRPSummary
Set x = .Range(Cells([ESDataRow1].Row, [ESCaseNum].Column), Cells(lastEIRPSummaryRow, [ESCaseNum].Column))
Set y1 = .Range(Cells([ESDataRow1].Row, [ESPriSpec100].Column), Cells(lastEIRPSummaryRow, [ESPriSpec100].Column))
Set y2 = .Range(Cells([ESDataRow1].Row, [ESPriPred100].Column), Cells(lastEIRPSummaryRow, [ESPriPred100].Column))
Set y3 = .Range(Cells([ESDataRow1].Row, [ESPriPred95].Column), Cells(lastEIRPSummaryRow, [ESPriPred95].Column))
Set y4 = .Range(Cells([ESDataRow1].Row, [ESPriPred90].Column), Cells(lastEIRPSummaryRow, [ESPriPred90].Column))
End With
'more code ...
嘗試之前'單元格添加時期'.'也'像這樣:'Set x = .Range(.Cells([ESDataRow1] .Row,[ESCaseNum] .Column),.Cells(lastEIRPSummaryRow,[ESCaseNum] .Column))' –
@simoco that worked。你已經做到了,我非常感激。 – jmaz