|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Private Sub getbasedata_Click() '处理学生基本情况
Dim pycyarray(31, 7) As String
Title = "今宵是何年"
yeardata = "请输入年份"
cffilenum = 0
nextinputyear:
yeardata = InputBox(yeardata, Title)
Dim intReturn As Integer
intReturn = MsgBox("你输入的年份是:" & yeardata, vbYesNoCancel, "提示")
If intReturn = vbYes Then GoTo letuswork
If intReturn = vbNo Then GoTo nextinputyear
If intReturn = vbCancel Then GoTo workover
letuswork: Workbooks.Open ThisWorkbook.Path & "\" & yeardata & "年经济困难家庭评议分组成员表.xls"
With Workbooks(yeardata & "年经济困难家庭评议分组成员表.xls").Sheets("sheet1")
For i = 1 To 31
pycyarray(i, 0) = Sheets("sheet1").Cells(i + 1, 1).Value
For j = 1 To 7
pycyarray(i, j) = Sheets("sheet1").Cells(i + 1, j + 2).Value
Next j
Next i
End With
ActiveWorkbook.Close False
sourceline = 3
Workbooks.Open ThisWorkbook.Path & "\" & yeardata & "经济调查总表.xls"
zmdlastline = Sheets("sheet1").Range("C65536").End(xlUp).Row
zmdnum = zmdlastline - 2
risenum = zmdnum Mod 31
Workbooks.Open ThisWorkbook.Path & "\经济调查评分模板.xls"
For k = 1 To 31
目标1 = ThisWorkbook.Path & "\" & yeardata & "评分表"
On Error Resume Next
VBA.MkDir (目标1)
目标2 = 目标1 & "\" & yeardata & "评分表" & pycyarray(k, 0) & "评分表"
VBA.MkDir (目标2)
rwnum = Int(zmdnum / 31)
If risenum > 0 Then rwnum = rwnum + 1
If risenum > 0 Then risenum = risenum - 1
Workbooks.Open ThisWorkbook.Path & "\评分结果表.xls"
Workbooks("评分结果表.xls").Sheets("评分结果表").Cells(1, 1) = "兴安中学" & yeardata & "年经济困难评议" & pycyarray(k, 0) & "评分结果表"
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Cells(1, 1) = rwnum
For rw = 1 To rwnum
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Cells(2 * rw, 14) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 53).Value
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Cells(2 * rw, 12) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 30).Value
Workbooks("评分结果表.xls").Sheets("评分结果表").Cells(rw + 2, 1) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 53).Value
Workbooks("评分结果表.xls").Sheets("评分结果表").Cells(rw + 2, 2) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 2).Value
Workbooks("评分结果表.xls").Sheets("评分结果表").Cells(rw + 2, 3) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 6).Value
For colnum = 2 To 11
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Cells(rw * 2, colnum) = Workbooks(yeardata & "经济调查总表.xls").Sheets("sheet1").Cells(sourceline, 2 * colnum + 27).Value
Next colnum
sourceline = sourceline + 1
Next rw
r =rwnum +1
Sheets("评分结果表").Cells.Borders.LineStyle = 0
Sheets("评分结果表").[A2].Resize(r, 15).Borders.LineStyle = 1
Workbooks("评分结果表.xls").SaveCopyAs (目标1 & "\" & pycyarray(k, 0) & "评分总表.xls")
ActiveWorkbook.Close False
r = rwnum + 1
Sheets("sheet1").Cells.Borders.LineStyle = 0
Sheets("sheet1").[A1].Resize(r, 14).Borders.LineStyle = 1
For m = 1 To 7
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Cells(27, 1) = pycyarray(k, m)
ActiveWorkbook.SaveCopyAs (目标2 & "\" & pycyarray(k, 0) & pycyarray(k, m) & "评分表.xls")
Next m
Workbooks("经济调查评分模板.xls").Sheets("sheet1").Range("B2:L121").ClearContents
Next k
ActiveWorkbook.Close False
ActiveWorkbook.Close False
workover:
End Sub
|
|