我有一个范围,首先我用公式填充,然后我试图将其转换为一个值,然后我使用sumifs基于标准的范围。然而,我得到的是
类型不匹配错误
在我使用Sumifs的那一行。我想我的错误来自于把公式的值改成了值。然而,我不能使用Select, Copy, PasteSpecial,因为我有超过2084行。我已经挣扎了相当长的一段时间。有什么建议吗?
Dim DWR, MHR, P, D As Worksheet
Set DWR = Sheets("DWREP")
Set MHR = Sheets("MACH-HRS")
Set P = Sheets("PRODUCTION")
Set D = Sheets("DELAYS")
Dim planned_time, tech_time, lost_time, std_time As Long
Dim last_row, last_row1, last_row2 As Long
last_row = MHR.Cells(Rows.Count, 1).End(xlUp).Row
last_row1 = P.Cells(Rows.Count, 1).End(xlUp).Row
last_row2 = D.Cells(Rows.Count, 1).End(xlUp).Row
If P.range("CC2").Formula = "" Then
P.range("CC2").FormulaR1C1 = "=PRODUCTION!RC[-66]/VLOOKUP(PRODUCTION!RC[-76],STD!R3C1:R1030C17,17,FALSE)"
P.range("CC2").AutoFill Destination:=P.range("CC2:CC" & last_row1), Type:=4
P.range("CC2:CC" & last_row1).Font.Color = RGB(255, 255, 255)
With P
With .range("CC2" & last_row1)
.Value = .Value
End With
End With
End If
std_time = Application.SumIfs(P.range("CC2:CC" & last_row1), P.range("A2:A" & last_row1), DWR.Cells(7, i), P.range("C2:C" & last_row1), DWR.range("B31"))
你缺少了你的那一列 With
块。
变化。.range("CC2" & last_row1)
为:.range("CC2:CC" & last_row1)