|
i = 0
For i = 1 To F_count
TextBox2.Text = TextBox2.Text & Chr(13) & "读取:" & F_name(i)
Dim wb As Workbook '定义一个工作簿对象
On Error Resume Next '容错语句,允许下面的代码发生非编译性可捕获错误
Set wb = Workbooks(F_name(i)) '查看工作簿是否打开
'如果制定工作簿没有打开,那么将发生错误9(“下标越界”)
'那么通过Err.Number =9来捕获这个错误,然后通过Workbooks.Open打开指定工作簿
msg = MsgBox("Err.Number:" & Err.Number)
If Err.Number = 9 Then
Set wb = Workbooks.Open(Path & F_name(i))
'msg = MsgBox(wb.Path)
End If
'-----调用试算平衡表模块-----
TextBox2.SetFocus
T_name = "试算平衡表(2012)"
xls_count = F_count
F_i = i
Sum_per = 0
'Workbooks(M_name).Sheets(T_name).Activate
'Workbooks(M_name).Sheets(T_name).Select
TextBox2.Text = TextBox2.Text & Chr(13) & "处理表:【" & T_name & "】"
Ss_12 = Summary_Ssph(wb, T_name, F_name(i), xls_count, F_i, Sum_per)
wb.Close True
Public Function Summary_Ssph(wb As Workbook, T_name, F_name, xls_count, i, Sum_per)
Dim wksht As Worksheet '定义一个工作表对象
On Error Resume Next '容错语句,允许下面的代码发生非编译性可捕获错误
wksht = wb.Worksheets(T_name)
msg = MsgBox(wksht.Cells(5, 1))
Ss_j = 0
For Ss_j = 5 To 19
Cells(Ss_j, 3).Value = Cells(Ss_j, 3).Value + wksht.Cells(Ss_j, 3)
msg = MsgBox(wksht.Cells(Ss_j, 3).Value)
TextBox2.Text = TextBox2.Text & Chr(13) & "数据更新:" & T_name & Trim(Cells(Ss_j, 1)) & "-" & Cells(Ss_j, 3)
Label8.Width = (Label7.Width / xls_count / 4273) * (Sum_per + Ss_j) + ((i - 1) * (Label7.Width / xls_count))
Label8.Caption = Format((100 / xls_count / 4273) * (Sum_per + Ss_j) + ((i - 1) * (100 / xls_count)), "0.00") & "%"
Next
end function
Cells(Ss_j, 3).Value 的值填不进去汇总表里, wksht.Cells(Ss_j, 3)是正常获取的!
求解!
|
|