Excel vba sumifs在带有条件的多个范围对象上
我正在尝试构建一个宏来创建基于具有2个标准的Sumifs公式的表。 第一个标准范围从没有表格格式的表中获取值,并且每天的行数都会更改,因此我使用Internet中的Lastrow示例。这种情况的标准是“ C”用于在西班牙购买的“ C”
第二条标准范围是同一表中的另一列,而无需表格格式和标准2来自枢轴表中的一行的
'Generar Formulas de a Partir de L (C= Montos de Compra)
Range("L" & Rows.Count).End(xlUp).Offset(3).Select
ActiveCell.FormulaR1C1 = "C"
Range("L" & Rows.Count).End(xlUp).Offset(1).Select
'Se aplica la formula de SUMIFS para dos condiciones, de Operación y tit
Dim lRowJ As Long
Dim lRowAA As Long
Dim lRowV As Long
Dim rngCriterio1 As Range
Dim rngCriterio2 As Range
Dim rngSuma As Range
'Asignación de los rangos
lRowJ = Range("J" & Rows.Count).End(xlUp).Row
lRowAA = Range("AA" & Rows.Count).End(xlUp).Row
lRowV = Range("V" & Rows.Count).End(xlUp).Row
Set rngCriterio1 = Range("J2" & lRowJ)
Set rngCriterio2 = Range("AA2" & lRowAA)
Set rngSuma = Range("V2" & lRowV)
'Uso de los rangos en la fórmula.
Range(ActiveCell, ActiveCell) = WorksheetFunction.SumIfs _
(rngSuma, rngCriterio1, "C", rngCriterio2, "=RC[-9]")
'Liberación de los objetos.
Set rngCriterio1 = Nothing
Set rngCriterio2 = Nothing
Set rngSuma = Nothing
' Se autocompleta con la formula
Dim ultimaFila As Long
ultimaFila = Range("C" & Rows.Count).End(xlUp).Row
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":L" & ultimaFila)
值在每个自动完成的单元格中,它甚至都不放置公式
I'm trying to build a macro to create a table based on SUMIfs formula with 2 criteria.
The first criteria Range takes values from a table without table format and the number of rows changes daily, so I use LastRow examples from the internet. and the criteria for this case is "C" for purchasing in Spanish
the second criteria Range is another column from the same table without table formatting and criteria 2 comes from the value of a row within a pivot table
'Generar Formulas de a Partir de L (C= Montos de Compra)
Range("L" & Rows.Count).End(xlUp).Offset(3).Select
ActiveCell.FormulaR1C1 = "C"
Range("L" & Rows.Count).End(xlUp).Offset(1).Select
'Se aplica la formula de SUMIFS para dos condiciones, de Operación y tit
Dim lRowJ As Long
Dim lRowAA As Long
Dim lRowV As Long
Dim rngCriterio1 As Range
Dim rngCriterio2 As Range
Dim rngSuma As Range
'Asignación de los rangos
lRowJ = Range("J" & Rows.Count).End(xlUp).Row
lRowAA = Range("AA" & Rows.Count).End(xlUp).Row
lRowV = Range("V" & Rows.Count).End(xlUp).Row
Set rngCriterio1 = Range("J2" & lRowJ)
Set rngCriterio2 = Range("AA2" & lRowAA)
Set rngSuma = Range("V2" & lRowV)
'Uso de los rangos en la fórmula.
Range(ActiveCell, ActiveCell) = WorksheetFunction.SumIfs _
(rngSuma, rngCriterio1, "C", rngCriterio2, "=RC[-9]")
'Liberación de los objetos.
Set rngCriterio1 = Nothing
Set rngCriterio2 = Nothing
Set rngSuma = Nothing
' Se autocompleta con la formula
Dim ultimaFila As Long
ultimaFila = Range("C" & Rows.Count).End(xlUp).Row
Selection.AutoFill Destination:=Range(ActiveCell.Address & ":L" & ultimaFila)
however, the result it throws is zero in each cell that is autocompleted, it does not even put the formula
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论