代码怎样解释?
Private Sub CommandButton2_Click()Dim Moth As Integer
Dim Maxrow As Integer, I As Integer
Dim CNN As New ADODB.Connection
Dim RS As New ADODB.Recordset
Dim pthStr As String
Dim SQL As String
Application.ScreenUpdating = False
pthStr = ThisWorkbook.Path & Application.PathSeparator & "分录表2013.mdb"
CNN.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & pthStr
Sheets("总分类账").[G4] = Format(, "00") & "月"
Maxrow = [A65536].End(xlUp).Row
If ComboBox1.Value = "" Then
CNN.Close
Exit Sub
Else
PBar1.Max = Maxrow - 7
For I = 7 To Maxrow
PBar1.Value = I - 7
SQL = " Select sum(iif(isnull(借方金额),0,借方金额)),sum(iif(isnull(贷方金额),0,贷方金额)) from (" & _
"select 月,借方金额,贷方金额 from flb where 科目编码 like '" & CStr(Cells(I, 1)) & "') where 月=" & CInt(ComboBox1.Value)
RS.Open SQL, CNN, adOpenKeyset, adLockOptimistic
Cells(I, "F").CopyFromRecordset RS
Set RS = Nothing
Next I
PBar1.Max = Maxrow - 7
For I = 7 To Maxrow
PBar1.Value = I - 7
SQL = " Select sum(iif(isnull(借方金额),0,借方金额)),sum(iif(isnull(贷方金额),0,贷方金额)) from (" & _
"select 月,借方金额,贷方金额 from flb where 科目编码 like '" & CStr(Cells(I, 1)) & "') where 月<=" & CInt(ComboBox1.Value)
RS.Open SQL, CNN, adOpenKeyset, adLockOptimistic
Cells(I, "H").CopyFromRecordset RS
Set RS = Nothing
Next I
End If
CNN.Close
Call 合计
Unload Me
Application.ScreenUpdating = True
MsgBox "总分类账的数据汇总完毕!", vbInformation, "凭证处理系统"
End Sub