精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學習啦>學習電腦>工具軟件>辦公軟件學習>金山WPS教程>WPS表格教程>

      WPS表格怎樣添加篩選唯一值功能

      時間: 廣達646 分享

        篩選功能是電子表格軟件很重要的一塊內(nèi)容,無論是ET還是Excel,都具有強大的篩選功能,但比較遺憾的是,ET和Excel都沒有“篩選唯一值”功能。接下來由學習啦小編為大家推薦WPS表格添加篩選唯一值功能的技巧,希望對你有所幫助!

        WPS表格添加篩選唯一值功能的教程:

        這里之所以說是模擬而不是實現(xiàn),是因為,VBA是無法操作ET或Excel的篩選器的,所以我們只好退而求其次,用隱藏行的方法來模擬“篩選唯一值”。

        這里給出VBA代碼(最多可以處理32767行數(shù)據(jù)):

        (這里給的是核心代碼,不包括下圖中創(chuàng)建按鈕的代碼)

        Public Sub 篩選唯一值() '最多可以處理32767行數(shù)據(jù)

        Application.ScreenUpdating = False '關閉屏幕更新,加快速度

        Dim cell As Range, i As Long, rng As Range, only As New Collection

        If TypeName(Selection) <> "Range" Then Exit Sub ' 選擇對象不是單元格則退出

        If Selection.Columns.Count > 1 Then

        MsgBox "只能選擇一列數(shù)據(jù)!", 0 + 64, "天遠篩選唯一值"

        Exit Sub

        End If

        Set rng = Intersect(ActiveSheet.UsedRange, Selection)

        On Error Resume Next

        For j = 1 To rng.Count '遍歷選區(qū)所有單元格

        If rng(j) <> "" Then

        only.Add rng(j).Value, CStr(rng(j).Value) '逐個導入 Collection對象

        End If

        If Err <> 0 Then '如果有錯誤(重復)

        i = i + 1 '累加變量

        '如果變量i為1則將 Selection(j)賦值給rng,否則將rng與 Selection(j)合并為一個Range對象

        If i = 1 Then

        Set cell = Selection(j)

        Else

        Set cell = Union(cell, rng(j))

        End If

        Err.Clear '清除錯誤

        End If

        Next j

        cell.EntireRow.Hidden = True '隱藏所有符合條件的行

        Application.ScreenUpdating = True

        End Sub

        復制代碼

        示例圖如下:

      347547