0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Excel VBA] オートフィルタ/フィルタを解除する

Last updated at Posted at 2024-08-19

ざっくり説明

オートフィルタ/フィルタを解除します。

コード

オートフィルタを解除
Function DeleteAutoFilter(ByVal WS As Worksheet)
'================================
'用途  :オートフィルタの解除
'--------------------------------
'第一引数:Worksheetオブジェクト (Worksheet型)
'戻り値 :なし
'================================
    If WS.AutoFilterMode Then
        WS.Cells(1, 1).AutoFilter
    End If
End Function
フィルタを解除
Function ClearFilter(ByVal WS As Worksheet)
'================================
'用途  :フィルタの解除
'--------------------------------
'第一引数:Worksheetオブジェクト (Worksheet型)
'戻り値 :なし
'================================
    If WS.FilterMode Then
        WS.ShowAllData
    End If
End Function

使用方法

第一引数に解除したいオートフィルタ/フィルタのあるWorksheetオブジェクトを渡す。

仕様等

特筆すべきこと無し

注意点

特筆すべきこと無し

その他

  • フィルタを解除して処理を動かしたい場合や、
    保存前にオートフィルタ/フィルタを削除したい場合に重宝
  • オートフィルタを解除すればフィルタも解除されます

フィルタとオートフィルタって何が違うねん、って方 向け解説

  • オートフィルタ
    データを絞り込むため、表に設定するもの
    ON(True)の場合、セルの右下に[▼]が表示される

  • フィルタ
    データを個別に絞り込むための設定値
    名簿を例に挙げると「男性のみ」「あ行の苗字の人のみ」etc

稚拙な説明ですがこんな感じです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?