|
Sub chaifen()
Dim sh As Sheet1, rng As Range
Set sh = ThisWorkbook.Worksheets("202007")
Set sh1 = ThisWorkbook.Worksheets("最低工资标准补发OR扣回列明细")
Set sh2 = ThisWorkbook.Worksheets("工资事项告知")
ar = sh.[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
sh.Copy
Set wb = ActiveWorkbook
With wb.Worksheets(1)
For s = 2 To UBound(ar)
If Trim(.Cells(s, 2)) <> Trim(ar(i, 2)) Then
If rng Is Nothing Then
Set rng = .Rows(s)
Else
Set rng = Union(rng, .Rows(s))
End If
End If
Next s
rng.Delete
End With
ThisWorkbook.Worksheets(Array("最低工资标准补发OR扣回列明细", "工资事项告知")).Copy after:=wb.Worksheets(wb.Worksheets.Count)
Set rng = Nothing
wb.SaveAs Filename:=ThisWorkbook.Path & "\" & ar(i, 2)
wb.Close
End If
Next i
MsgBox "ok!"
End Sub
|
|