Μετάβαση στο κύριο περιεχόμενο

Πώς να φιλτράρετε αυτόματα τις σειρές με βάση την τιμή κελιού στο Excel;

Κανονικά, η λειτουργία Φίλτρο στο Excel μπορεί να μας βοηθήσει να φιλτράρουμε όσα δεδομένα χρειαζόμαστε, αλλά, μερικές φορές, θα ήθελα να φιλτράρω αυτόματα κελιά με βάση μια χειροκίνητη είσοδο κελιού που σημαίνει ότι όταν εισάγω κριτήρια σε ένα κελί, τα δεδομένα μπορούν να είναι φιλτράρεται αυτόματα ταυτόχρονα. Υπάρχουν καλές ιδέες για την αντιμετώπιση αυτής της εργασίας στο Excel;

Αυτόματο φίλτρο σειρών με βάση την τιμή κελιού που εισαγάγατε με τον κωδικό VBA

Φιλτράρετε δεδομένα βάσει πολλαπλών κριτηρίων ή άλλης συγκεκριμένης κατάστασης, όπως κατά μήκος κειμένου, κατά περίπτωση


Αυτόματο φίλτρο σειρών με βάση την τιμή κελιού που εισαγάγατε με τον κωδικό VBA

Ας υποθέσουμε, έχω το ακόλουθο εύρος δεδομένων, τώρα, όταν εισάγω τα κριτήρια στα κελιά E1 και E2, θέλω τα δεδομένα να φιλτραριστούν αυτόματα όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης:

αυτόματο φίλτρο doc 1

1. Μεταβείτε στο φύλλο εργασίας που θέλετε να φιλτράρετε αυτόματα την ημερομηνία με βάση την τιμή κελιού που εισαγάγατε.

2. Κάντε δεξί κλικ στην καρτέλα φύλλων και επιλέξτε Προβολή κωδικού από το μενού περιβάλλοντος, στο αναδυόμενο Microsoft Visual Basic για εφαρμογές παράθυρο, αντιγράψτε και επικολλήστε τον ακόλουθο κώδικα στο κενό Μονάδα μέτρησης παράθυρο, δείτε το στιγμιότυπο οθόνης:

Κωδικός VBA: δεδομένα αυτόματου φίλτρου σύμφωνα με την τιμή του κελιού

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice 20160606
   If Target.Address = Range("E2").Address Then
       Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2")
   End If
End Sub

αυτόματο φίλτρο doc 2

Note: Στον παραπάνω κώδικα, Α1: Γ20 είναι το εύρος δεδομένων που θέλετε να φιλτράρετε, E2 είναι η τιμή-στόχος στην οποία θέλετε να φιλτράρετε βάσει και E1: E2 είναι το κριτήριό σας θα φιλτραριστεί βάσει. Μπορείτε να τα αλλάξετε ανάλογα με τις ανάγκες σας.

3. Τώρα, όταν εισάγετε τα κριτήρια στο κελί E1 και E2 και πατήστε το πλήκτρο εισάγετε κλειδί, τα δεδομένα σας θα φιλτράρονται αυτόματα από τις τιμές των κελιών


Φιλτράρετε δεδομένα βάσει πολλαπλών κριτηρίων ή άλλης συγκεκριμένης κατάστασης, όπως κατά μήκος κειμένου, κατά περίπτωση

Φιλτράρετε δεδομένα βάσει πολλαπλών κριτηρίων ή άλλης συγκεκριμένης κατάστασης, όπως κατά μήκος κειμένου, κατά κεφαλαίο κ.λπ.

Kutools για Excel'S Σούπερ φίλτρο η δυνατότητα είναι ένα ισχυρό βοηθητικό πρόγραμμα, μπορείτε να εφαρμόσετε αυτήν τη δυνατότητα για να ολοκληρώσετε τις ακόλουθες λειτουργίες:

  • Φιλτράρετε δεδομένα με πολλαπλά κριτήρια. Φιλτράρετε δεδομένα κατά μήκος κειμένου.
  • Φιλτράρετε δεδομένα με κεφαλαία / πεζά γράμματα. Φιλτράρετε την ημερομηνία ανά έτος / μήνα / Ημέρα / εβδομάδα / τρίμηνο

Kutools για Excel: με περισσότερα από 300 εύχρηστα πρόσθετα του Excel, δωρεάν δοκιμή χωρίς περιορισμό σε 30 ημέρες. Λήψη και δωρεάν δοκιμή τώρα!


Επίδειξη: Αυτόματο φίλτρο σειρών με βάση την τιμή κελιού που εισαγάγατε με τον κώδικα VBA

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 50% και μειώνει εκατοντάδες κλικ του ποντικιού για εσάς κάθε μέρα!
Comments (36)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
hi

thank you - this code was a life saver

but if I wish to filter when the value on E2 contains the search text.
so if i search for Grade1
it should filter
Grade1
ExampleGrade1
Grade1ETC


many thanks in advance
This comment was minimized by the moderator on the site
I scanned through the comments and didn't see a specific answer. I am looking to filter a Table that changes based on a DB query, The table range will change every time the query is refreshed, How can we account for this in the code? The function becomes pointless if I have to direct users edit the VBA code every time they refresh the table.
This comment was minimized by the moderator on the site
Good day,

I have made sheet1 with the table in the example. In sheet2 all the data are referenced to the table in sheet1.

In sheet2 I can choose the grades exactly as in the example. That works OK.

However when I change a Grade of a student in sheet1 the list is not updated in sheet2. So the filter does not work automatic.

How can this be done?
This comment was minimized by the moderator on the site
Hello, is there a way to quickly modify the VBA code to filter on values bigger than in selected cell?
This comment was minimized by the moderator on the site
Hi there,

Thank you for the great content, however I am having some issues and was wondering whether you had any ideas why.

I have adjusted my ranges so my code reads:

Sub AutoFilter()
If Target.Address = Range("E13:F14").Address Then
Worksheets('Data Archive').Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("F10:F1048576")
End If
End Sub


However, when I run the macro a "Compile Error: Syntex Error" message appears.

Thank you in advance

Stan
This comment was minimized by the moderator on the site
Hello, Stan,
Do you set the data range and criteria range correctly in the code?Or you can take your data range as a screenshot here.
Thank you!
This comment was minimized by the moderator on the site
Thank you very much for this. It worked for me fine to a certain extent, please let me explain:

I have multiple tables in my workbook. When I applied the above code, it only worked for one table, but not for the other two tables. Let's say the first table is, as in your example, from A1:C20. The second table is from A22:C40. The third from A42:C60. All tables have the info about the "Grade", however they have different columns & Date and therefore cannot be consolidated into one big tables but rather 3 smaller tables.

How would the code need to like like so that if I put the criteria: "Grade1", all 3 tables will be automatically filtered for "Grade1" ?

Thank you very much in advance.

Best regards
This comment was minimized by the moderator on the site
Thank you, for this, it was really helpful. i just have one question, after selected the name in the drop down menu (i have names as criteria), it only shows people with that name, as it should, but how can i do so after i have selected a name, then i want so see all the rows of my table??

hope you can help me out.

kind regards
This comment was minimized by the moderator on the site
Hi, Peter,
This code is worked well for fitering the entire rows of the data, could you enter your table range correctlly?

A1:C20 is the range of your data, E1:E2 is the criteria range.
Range("A1:C20").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("E1:E2")
This comment was minimized by the moderator on the site
Hey guys,
perfect Explanation, thank you very much.
1 Little question: if I want to filter with 2,3 4 or more criterias how do I do this?
For example I want to say I wanna see the Name Henry, with Grade 1 and this Age...so not just 1 criteria but for example 3..=?


thanks for the respond


Kind regards,


TIM
This comment was minimized by the moderator on the site
Hi, tim,
To auto filter data based on multiple criteria, you should apply the below code: (please change the cell references to your need)

Private Sub Worksheet_Change(ByVal Target As Range)
'Update by Extendoffice
Dim xVStr As String
Dim xFStr As String
xVStr = "E22:G22" 'the criteria that you want to filter based on
xFStr = "E21:G22" 'the range contains the header of the criteria
If Not (Intersect(Range(xVStr), Target) Is Nothing) Then
Range("A1:C17").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Range(xFStr)
End If
End Sub


Please try, hope it can help you!
This comment was minimized by the moderator on the site
Hello,

What if I got the filtered data in a different tab(sheet 2) in the same workbook and the cell that the filter needs to refer to is in the first tab(sheet 1). I used this VBA but is not working like that, only if I have both the criteria cell(E2 in this VBA) in the same tab with the filtered data(A1:C20)
This comment was minimized by the moderator on the site
There might be a mistake in the instructions. Instead of pasting the code into a blank Module, one should paste it into the Sheet window. For example, if the macro is to work on Sheet1, the code should be pasted into Microsoft Excel Objects -> Sheet1(Sheet1). Only then it works for me on Excel 2016.

Thanks for the code!
This comment was minimized by the moderator on the site
Hi, mjr,
There is no mistake in this article, the article said, you should put the VBA code into the sheet module by right click the sheet name and then choose View Code to go to the module.
But, your operation is correct as well.
Thank you for your comment.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations