|
楼主 |
发表于 2016-12-21 14:49
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub aa()
Dim arr, x&, arr1()
With Sheets("员工表")
arr = .Range("A3:x" & .Range("A65536").End(xlUp).Row)
End With
For x = 2 To UBound(arr)
If arr(x, 1) = "离职" Then
i = i + 1
ReDim Preserve arr1(1 To UBound(arr, 2), 0 To i)
arr1(1, i) = i
For y = 2 To UBound(arr, 2)
arr1(y, i) = arr(x, y)
Next y
End If
Next x
For x = 1 To UBound(arr, 2)
arr1(x, 0) = arr(1, x)
Next x
Sheets("离职管理").Select
Columns("A:x").Borders.LineStyle = 0
Columns("A:x").ClearContents
Range("A1").Resize(UBound(arr1, 2) + 1, UBound(arr1)) = Application.Transpose(arr1)
Range("A1").Resize(UBound(arr1, 2) + 1, UBound(arr1)).Borders.LineStyle = 1
Columns("B:G").Select
With Sheets("离职管理").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("G2:G200"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range("B1:G200")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
End Sub
|
|