【发布时间】:2020-12-18 22:45:02
【问题描述】:
请找到以下示例,我想在其中对我的实际数据集的其余部分进行编码,
ColumnA 有多个州名,ColumnB 有唯一值,在columnC 中,我们想要columnB 和Merging cells 的sumif 基于州名(columnA)的结果。
Dim ColumnA as long
Dim ColumnC as long
ColumnsC = 0
ColumnA = Worksheets("Sheet1").Cells(2, 1).value
Lastrow = Worksheets("sheet1").cells(Rows.Count, 1).End(xlUp).Row
For i = 2 to lastrow
IF Worksheets("Sheet1").Cells(i, 1).value = ColumnA Then
ColumnC = ColumnC + Worksheets("Sheet1").cells(i, 3).value
End if
Next
worksheets("sheet1").cells(2, 3).value = ColumnC
【问题讨论】:
-
没有问题。请查看How to Ask。 minimal reproducible example 也可能有助于改善您的问题。请添加示例输入数据和所需的输出。还要解释你的代码有什么问题。
-
一个非常可靠的经验法则:不要合并单元格。为什么数据透视表在这里不起作用?
标签: excel vba excel-formula