我一直在
“运行时错误'1004' 应用程序定义或对象定义的错误。“
参考这些行。
Worksheets("5001 Prog").Range("C12").Value = (y & "'' Ream")
Worksheets("5001 Prog").Range("D12").Value = count * 31.5
Worksheets("5001 Prog").Range("E12").Value = daily * 31.5
事情就是这个代码在我关闭文件并重新打开之前工作了。此外,如果我重新排列线条有时他们工作。我尝试将“count”和“daily”变量更改为等于“12”然后在上面的代码中处理它们仍然返回错误。
我已经查看了此错误代码的多个答案,并尝试了这些帖子中提到的多个内容,但没有任何效果。我感谢所有的反馈,谢谢。
P.S。我知道“If”语句中的代码是垃圾,我还在努力。但代码确实在“if”语句现在处于状态。
Sub Update_Last()
Worksheets("5001 Prog").Unprotect "Welcome1"
Worksheets("Drill Log").Unprotect "Welcome1"
Dim w As Integer
Dim x As Integer
Dim y As Integer
Dim z As String
w = 39
x = Worksheets("Drill Log").Range("E39").Value
y = Worksheets("Drill Log").Range("E39").Value
z = Worksheets("Drill Log").Range("D39").Value
If z = Worksheets("Variables").Range("H10").Value Then
Do Until Not x = y
y = Worksheets("Drill Log").Range("E" & w).Value
w = w + 1
z = Worksheets("Drill Log").Range("D" & w).Value
Loop
ElseIf z = Worksheets("Variables").Range("H14").Value Then
Do Until Not x = y
y = Worksheets("Drill Log").Range("E" & w).Value
w = w + 1
z = Worksheets("Drill Log").Range("D" & w).Value
Loop
Else
w = w + 1
z = Worksheets("Drill Log").Range("D" & w).Value
End If
Dim count As Integer
count = Application.WorksheetFunction.CountIfs(Worksheets("Drill Log").Range("Drill_Log[Pass Type]"), "Ream", Worksheets("Drill Log").Range("Drill_Log[Size]"), y)
Dim daily As Integer
daily = Application.WorksheetFunction.CountIfs(Worksheets("Drill Log").Range("Drill_Log[Pass Type]"), "Ream", Worksheets("Drill Log").Range("Drill_Log[Size]"), y, Worksheets("Drill Log").Range("Drill_Log[Foreman]"), Worksheets("5001 Prog").Range("B5").Value, Worksheets("Drill Log").Range("Drill_Log[Date]"), Worksheets("5001 Prog").Range("E4").Value)
Worksheets("5001 Prog").Range("C12").Value = (y & "'' Ream")
Worksheets("5001 Prog").Range("D12").Value = count * 31.5
Worksheets("5001 Prog").Range("E12").Value = daily * 31.5
Worksheets("5001 Prog").Protect "Welcome1"
End Sub