|
Sub div()
Dim myrow As Long
Dim mycol As Long
Dim i As Long
myrow = [a65536].End(xlUp).Row
mycol = [iv1].End(xlToLeft).Column
Range("A1:A" & myrow).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Range("A2:A" & myrow).SpecialCells(xlCellTypeVisible).Copy Destination:=Cells(1, mycol + 1)
ActiveSheet.ShowAllData
Range(Cells(1, 1), Cells(1, mycol)).AutoFilter
For i = 1 To Application.CountA(Columns(mycol + 1))
Sheets.Add
ActiveSheet.Name = Cells(i, mycol + 1)
Range(Cells(1, 1), Cells(1, mycol)).AutoFilter Field:=1, Criteria1:=Cells(i, mycol + 1)
Range(Cells(1, 1), Cells(myrow, mycol)).SpecialCells(xlCellTypeVisible).Copy Destination:=ActiveSheet.Range("a1")
Next
Sheets("sheet1").Select
Range(Cells(1, 1), Cells(1, mycol)).AutoFilter
Columns(mycol + 1).ClearContents
End Sub |
|