r = mainWS.Cells(count, 1).Value
paths = mainWS.Cells(i, 2).Value
pathd = mainWS.Cells(i, 6).Value
.....
If (r = "H") Then
Application.Workbooks.Open (pathd & "\" & filed)
Set dWB = Application.Workbooks(filed)
Set tabD_WB = dWB.Sheets(tabd & "")
Application.Workbooks.Open (paths & "\" & files)
Set sWB = Application.Workbooks(files)
Set tabS_WB = sWB.Sheets(tabs & "")
End If
Set uRange = tabD_WB.Range(Cells(1, 1), Cells(5, tabD_WB.UsedRange.Columns.count))
因此,如果我将最后一行以 Set uRange 开头放在 IF 块内,则该练习将完美运行。如果我在之后/外面立即放置它,它不会。你能帮我理解为什么吗?
我得到的错误(如果它在外面)是Object required
. 这是Excel内部工作的一些错误吗?
我很困惑。非常感谢!