我在使用此代码时遇到问题。代码经过一列(列B),每当它看到一个特定的单词时,它将取位于列D中的值。例如,如果关键字位于B2中,那么它将取D2的值。下面我编写了迄今为止的编码。
import { distinctUntilChanged } from 'rxjs/operators';
答案 0 :(得分:0)
根据我的评论,可以使用以下公式来完成:
=SUMIF(Sheet1!B:B,"Payment",Sheet1!D:D)
但如果你想要vba:
代码:
Dim MyRange As Range
Dim rcell As Range
Dim i As Integer
Dim Sum_Payment As Double
Set MyRange = Worksheets("Sheet1").Range("B2:B50")
For Each rcell In MyRange.Cells
Debug.Print rcell.Address, rcell.Value
If rcell.Value = "Payment" Then
Sum_Payment = Sum_Payment + rcell.Offset(0,2).Value
Debug.Print Sum_Payment
End If
Next rcell
ThisWorkbook.Sheets("Sheet2").Range("B2") = Sum_Payment