|
Sub 按考核人员生成工作簿()
' 2022-3-25
Application.DisplayAlerts = False '关闭系统的对话框
mypath = ThisWorkbook.Path ' 这个工作的路径
' --
x2 = 2
Do While Not (IsEmpty(Sheet2.Cells(x2, 1).Value))
c_xm = Sheet2.Cells(x2, 1).Value
Sheet3.Select
Rows("2:20000").Select
Selection.Delete Shift:=xlUp ' 删除已有数据的行,以保证数据的正确
' --
x1 = 2
Do While Not (IsEmpty(Sheet1.Cells(x1, 5).Value))
If Sheet1.Cells(x1, 5).Value = c_xm Then
x3 = 2
Do While Not (IsEmpty(Sheet3.Cells(x3, 5).Value))
x3 = x3 + 1
Loop
For y = 1 To 22
Sheet3.Cells(x3, y).Value = Sheet1.Cells(x1, y).Value
Next y
End If
x1 = x1 + 1
Loop
' --
Sheet3.Select
Cells.Select
Selection.Copy
' --
Set wb = Workbooks.Add ' 新建一个工作簿
wb.Worksheets(1).Range("a1").Select
ActiveSheet.Paste ' 粘贴
wb.Worksheets(1).Name = c_xm ' 命名工作表名称
wb.SaveAs ThisWorkbook.Path & "\" & c_xm ' 保存
wb.Close True ' 关闭工作簿
' --
x2 = x2 + 1
Loop
End Sub |
|