Dim t As Table = Tables("表A") t.Sort = "日期 desc,金额 desc" Dim sum As Double = 1000 Dim idx As String = "-1," For Each r As Row In t.rows If sum >= r("金额") Then sum -= r("金额") idx &= r("_Identify") & "," Else idx &= r("_Identify") & "," Exit For End If Next t.filter = "_Identify in (" & idx.trim(",") & ")"