1 下载附件,点击按钮
2 按要求根据C列在本工作簿路径下创建N个工作簿并导入有关数据,新创建的工作簿按班级名称命名
3 不明白hi我
希望能帮到你
Sub 分班() '分班的表格在"我的文档"
Dim k, l, m, s
On Error Resume Next
k = 2
l = 3
m = InputBox("数据最下边一行的行数", , 12)
Do While Cells(l, 3) <> ""
Do While Cells(l, 3) = Cells(k, 3) And l < m
Cells(l, 3).Select
l = l + 1
Loop
s = Cells(l - 1, 3)
Range(Range("c" & l - 1), Range("c" & k)).Select
Selection.EntireRow.Copy
Workbooks.Add
Cells(1, 1) = "姓名"
Cells(1, 2) = "性别"
Cells(1, 3) = "班级"
Cells(1, 2) = "学籍辅号"
Rows("2:2").Select
Selection.Insert Shift:=xlDown
ActiveWorkbook.SaveAs Filename:="班级" & s
ActiveWorkbook.Close
k = l
l = k + 1
Loop
End Sub
可以先建一个模板文件,然后每选一个班级,打开这个模板,写入数据后另存为班级名
Workbooks.Open ThisWorkbook.Path & "\模板.xls"
Set c = ActiveWorkbook
‘写入数据
c.SaveAs ThisWorkbook.Path & "\“ & bjname & ".xls"
c.Close
我也经常遇到这个问题,先是经常需要把数据拆分到各个部门经理,后来又经常要把数据拆分到各个县。
也考虑用VBA实现,结果能实现了,但是因为数据量太大,电脑卡得比人工还慢,最后用python解决了,一分钟不到,完成所有拆分。
把G3改成10,然后在G4中输入:=IF(B4<$G$3,$B$3&",","")&IF(C4<$G$3,$C$3&",","")&IF(D4<$G$3,$D$3&",","")&IF(E4<$G$3,$E$3&",&quo...