|
在sheet2中:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a As String, b As String, c As Single
a = Range("a3").Value
a = Format(a, "m月d日")
b = Range("b3").Value
ThisWorkbook.Sheets(1).Select
With Sheets(1).Cells
.AutoFilter Field:=1, Criteria1:=a
.AutoFilter Field:=2, Criteria1:=b
c = Application.WorksheetFunction.Subtotal(9, .Range("C:C"))
.AutoFilter
End With
MsgBox (c)
Range("c3") = c
End Sub
在模块2中:
Function bree(a As String, b As String) As Single
a = Format(a, "m月d日")
ThisWorkbook.Sheets(1).Select
With Sheets(1).Cells
.AutoFilter Field:=1, Criteria1:="a"
.AutoFilter Field:=2, Criteria1:="b"
c = Application.WorksheetFunction.Subtotal(9, .Range("C:C"))
.AutoFilter
End With
bree = c
End Function
|
|