|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Public Sub 追加数据()
Application.ScreenUpdating = False '避免屏幕刷新时闪烁
Dim SMT As String
Dim xlsFile As String, Qwjm As String
Dim I As Integer, J As Integer
Dim Hrow1 As Integer, Hrow2 As Integer
Dim Lsj1 As String, Lsj2 As String, Lsj3 As Double
SMT = ThisWorkbook.Path
Sheets("TXCZ1").Activate
Range("A2:D1000").Clear
Columns("A:C").Select
Selection.NumberFormatLocal = "@"
Columns("D:D").Select
Selection.NumberFormatLocal = "0.00_ "
For I = 1 To 12
xlsFile = "\2007年" & I & "月离休.XLS"
Qwjm = "2007年" & I & "月离休.XLS"
Qwjm2 = "离休汇总.XLS"
Workbooks.Open SMT & xlsFile
Hrow1 = Range("B65536").End(xlUp).Row
For J = 2 To Hrow1
Workbooks(Qwjm).Activate
Lsj1 = Cells(J, 2)
Lsj2 = Cells(J, 3)
Lsj3 = Cells(J, 5)
Workbooks(Qwjm2).Activate
Worksheets("TXCZ1").Activate
Hrow2 = Range("B65536").End(xlUp).Row + 1
Cells(Hrow2, 1) = I & "月"
Cells(Hrow2, 2) = Lsj1
Cells(Hrow2, 3) = Lsj2
Cells(Hrow2, 4) = Lsj3
Lsj1 = ""
Lsj2 = ""
Lsj3 = 0
' ActiveWorkbook.Save
Next J
Workbooks(Qwjm).Close SaveChanges:=True
Next I
End Sub
这个程序是汇总12个工作簿的程序,12个工作簿分别是:1月离休,2月离休。。。11月离休,12月离休.xls,汇总表为:离休汇总.XLS。程序能自动汇总12月的数据。
[ 本帖最后由 weiguoyin868 于 2009-6-30 21:24 编辑 ] |
|