答案 0 :(得分:0)
答案 1 :(得分:0)
您始终希望尝试发布您尝试过的代码。请发布您的努力,鼓励人们出来帮助您。
我已经尝试了一段代码给你一个想法,请看看它们,如果有效,请告诉我。
Sub autofilter_copy()
'Declare the Required Variables
Dim Colm As Integer
Dim lastrow As Long
Dim i As Variant
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Activate
'Get Column Number of Designation Column
Colm = WorksheetFunction.Match("Designation", Sheets("Sheet1").Rows(1), 0)
'Get Last row of the Designation Column
lastrow = ActiveSheet.Cells(Rows.Count, Colm).End(xlUp).Row
' Usage of Advanced Filter to get the Unique Values
ActiveSheet.Range("C1:C13").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Sheet1").Range("D1"), Unique:=True
Range("D1").Value = "Designation Unique"
Colm2 = WorksheetFunction.Match("Designation Unique", Sheets("Sheet1").Rows(1), 0)
lastrow2 = ActiveSheet.Cells(Rows.Count, Colm2).End(xlUp).Row
'For loop to loop through the Unique values and paste the values in a new sheet.
For i = 2 To lastrow2
ws.Activate
UniqueValue = Range("D" & i).Value
Cells.Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$C" & lastrow).AutoFilter Field:=3, Criteria1:=UniqueValue
Cells.Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
ws.Activate
Next
End Sub