|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
个人:
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Address <> "$D$3" Then Exit Sub
- Dim Cn As Object, Sqlstr$
- Set Cn = CreateObject("Adodb.Connection")
- Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & ThisWorkbook.FullName
- Sqlstr = "Select 月,日,编号,摘要,岗位补贴,驻外补贴 " _
- & "From [补贴发放记录表$B4:H65536] " _
- & "Where 姓名='" & [D3] & "'"
-
- [5:65536].ClearContents
- [B5].CopyFromRecordset Cn.Execute(Sqlstr)
- Cn.Close: Set Cn = Nothing
- End Sub
复制代码 汇总:
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Address <> "$C$3" Then Exit Sub
- Dim Cn As Object, Sqlstr$
- Set Cn = CreateObject("Adodb.Connection")
- Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" & ThisWorkbook.FullName
- Sqlstr = "Select 姓名,Sum(岗位补贴),Sum(驻外补贴) " _
- & "From [补贴发放记录表$B4:H65536] " _
- & "Where 月=" & [C3] _
- & " Group By 姓名"
-
- [5:65536].ClearContents
- [B5].CopyFromRecordset Cn.Execute(Sqlstr)
- Cn.Close: Set Cn = Nothing
- End Sub
复制代码 |
|