0
我全新到Excel VBA,所以我感谢所有帮助。 我在Excel VBA以下代码数据与一定的条件下在过滤片上的数据之后创建在片输出两个单独的表。如何总结在VBA两个空单元格之间的列中的所有值?
Dim i, LastRow
LastRow = Sheets("data").Range("B" & Rows.Count).End(xlUp).Row
Sheets("output").Range("A2:L500").ClearContents
Sheets("output").Range("A" & Rows.Count).End(xlUp).Offset(1) = "first table"
For i = 2 To LastRow
If Sheets("data").Cells(i, "G").Value > 0 And Sheets("data").Cells(i, "G").Value <= 2 Then
Sheets("data").Cells(i, "G").EntireRow.Copy Destination:=Sheets("output").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
Sheets("output").Range("A" & Rows.Count).End(xlUp).Offset(3) = "second table"
For i = 2 To LastRow
If Sheets("data").Cells(i, "G").Value > 2 And Sheets("data").Cells(i, "G").Value <= 3 Then
Sheets("data").Cells(i, "G").EntireRow.Copy Destination:=Sheets("output").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
End Sub
我希望它做的是给一些特定的列(比如,列C)的所有值的总和为每个表(分别为表1和分别为表2)。