メインコンテンツへスキップ

 Excelで高度なフィルター結果を自動的に更新するにはどうすればよいですか?

高度なフィルター機能を適用すると、フィルターされた結果が基準の変更によって自動的に変更されないことがわかります。 これには、新しい結果を取得するために、高度なフィルター機能をもう一度適用する必要があります。 しかし、Excelに表示されている次のスクリーンショットのように、高度なフィルター結果を自動的に更新するための優れた簡単なトリックはありますか?

高度なフィルター結果をVBAコードで自動的に更新します


高度なフィルター結果をVBAコードで自動的に更新します

次のVBAコードは、必要に応じて基準を変更したときに、高度なフィルター結果を自動的に更新するのに役立つ場合があります。次のようにしてください。

1。 データを自動的にフィルタリングするシートタブを右クリックして、 コードを表示 コンテキストメニューから、開いた状態で アプリケーション用のMicrosoftVisual Basic ウィンドウで、次のコードをコピーして空のモジュールに貼り付けます。

VBAコード:高度なフィルター結果を自動的に更新します:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A5:D21").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range _
("A1:C3"), Unique:=False
End Sub

Note:上記のコードでは: A5:D21 フィルタリングするデータ範囲です。 A1:C3 に基づいてフィルタリングする基準範囲です。

2。 次に、コードウィンドウを保存して閉じます。これで、基準範囲の基準を変更すると、フィルタリングされた結果がすぐに自動的に更新されます。

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This is likely not relevant anymore. Office excel now has a FILTER function that auto updates from what I gather, making advanced filter a sort of weak pivot table. FILTER function is what should be used moving forward? Sounds like excel's solution to the issue you state above not requring VBA to do.
This comment was minimized by the moderator on the site
Hi, I am applying advanced filter for a single column for unique values(with no criteria) . I need it to be updated by itself.

Could you please help me with that?
This comment was minimized by the moderator on the site
Is there a way to do this without using VBA?
This comment was minimized by the moderator on the site
Hello, this code works perfectly, there is just one problem, the copy/paste fonction doesn't work anymore.
How could it be fixed?
Thanks in advance
This comment was minimized by the moderator on the site
@Hannah: Yes, it is possible.
In the following code the criteria is on the sheet "Filter".


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("A5:D23").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Sheets("Filter").Range("A1:C3"), Unique:=False
End Sub
This comment was minimized by the moderator on the site
Ce code donne une erreur 1004 référence non valide. pouvez vous corriger le code proposé?
This comment was minimized by the moderator on the site
Bonjour, merci pour votre post qui m'aide énormément. Toutefois quel serait le code à ajouter pour coller le résultat dans un tableau d'une autre feuille de fichier et si possible pour au passage ne coller que certaines colonnes ?
Pour être plus précise, en utilisant votre exemple je voudrais copier uniquement les colonnes "Product" et "Name" du résultat du filtre et ce dans une nouvelle feuille. Merci.
This comment was minimized by the moderator on the site
Can I make the criteria come from a second sheet?
This comment was minimized by the moderator on the site
it refreshes every time when any data changes.

is it possible to refresh only when criteria changes.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations