|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub aaa()
Dim a, b, c, xrow, yrow As Integer
Dim name As String
xrow = Range("a65536").End(3).Row
name = ""
b = 4
For a = 1 To xrow
If name <> Range("a" & a).Value Then
name = Range("a" & a).Value
Cells(1, b) = name
b = b + 1
End If
Next
yrow = Range("XFD1").End(1).Column
For b = 4 To yrow
Range("$A$1:$b$" & yrow).AutoFilter Field:=1, Criteria1:=Cells(1, b)
If Range("a1") = Cells(1, b) Then
Range("b1:b" & Range("b65536").End(3).Row).Copy Cells(2, b)
ElseIf Range("a1") <> Cells(1, b) Then
Range("b2:b" & Range("b65536").End(3).Row).Copy Cells(2, b)
End If
Next
Range("$A$1:$b$" & yrow).AutoFilter
End Sub
|
|