excel - 类型不匹配问题 VBA - 公式到值
问题描述
我有一个范围,首先我用公式填充然后我试图将它转换为一个值,然后我使用 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)
推荐阅读
- c# - WPF InputSimulator 不适用于用户控件
- java-8 - Java 8 - SQL 时间戳到即时格式正确的时间
- api - 没有“假期回复”的Gmail中的自动回复?
- git - 如何列出git未跟踪的文件并根据修改时间对其进行排序?
- python-3.x - 如何通过事件与 matplotlib 中的条进行交互
- python - “if”语句不移动到“else”子句
- c# - “AddReward”不添加奖励:Unity mlagents
- powershell - 无法将 xlsx 中的数据提取到 powershell
- go - 混合打印和 fmt.Println 和堆栈增长
- javascript - 是否可以从 Javascript 中的 require() 文件中“向后引用”某些内容?