+ Reply to Thread
Results 1 to 40 of 40

Filter function with evaluate

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Filter function with evaluate

    Hello everyone

    I have names in the range A1:A10 and A1 has the name "Yasser" and A7 has the name "Ahmed" and other cells with other names
    I have tried this line so as to filter and get the rows that has the value "Ahmed" or "Yasser"
    Please Login or Register  to view this content.
    But when following the code I found x has all the rows and I expect to get 1 and 7 row only
    Any help at this point.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot my tuotr. So is there a difference between ANd and using + ( I thought they are the same). And When I used AND instead of OR, I got an error.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    I don't understand what you are talking about.

    There is no "AND" function in your original formula string.

    + or "OR", * for "AND"

    Both "AND" & "OR" function only works in special conditions in Evaluate method.

  5. #5
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thank you very much. Now I got it.
    Best Regards

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    When I try to use it like that, I got an error
    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Number of opening bracket and closing bracket doesn't match.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    I adjusted the number of brackets and now no error but x in the Type column of Locals window is >> Variant/String (0 to -1)
    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    This is as in post #6 and this throws an error. Can you post it in full to make sure?

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Filter function with evaluate

    Code in Post#8 works just fine. With 5 names in range gives me Variant/String(0 to 4).

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Delete the red closing bracket.

  13. #13
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot. It was my fault as I was activating another sheet during the test process.
    Last question: how can I skip if the x is 0 to -1 (Would I use the Ubound(x) = -1?)
    And how to refer to sheet1 in the line .. so as to avoid the error if I was in another sheet?
    Last edited by YasserKhalil; 04-05-2020 at 03:53 AM.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Correct.............

    Sheets("Sheet1").Evaluate("........")
    Last edited by jindon; 04-05-2020 at 03:58 AM.

  15. #15
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thank you very much for all of you

    Last question: how can I skip if the x is 0 to -1 (Would I use the Ubound(x) = -1?)
    And how to refer to sheet1 in the line .. so as to avoid the error if I was in another sheet?

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Filter function with evaluate

    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    See my post #14

    Worksheet Evaluate method is the fastest.

  18. #18
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thank you very much for this great information. All is great now
    ** As for using Evaluate doesn't throws error when concatenting the line. But using the brackets [] throws error
    Isn't the use of [ __] is the same as Evaluate("__")?

    Please Login or Register  to view this content.

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    You can't use variable with a short cut notation of Evaluate, i.e. [].

  20. #20
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot for the information.
    I have enjoyed a lot this topic...

    Best Regards for All of You.

  21. #21
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Is it possible to get the part of Row(1:10) as a variable depending on a range
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    row(" & r.address & ")

  23. #23
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot and sorry for disturbing you again and again.. I am just try to learning more about this topic.

  24. #24
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    What if I decide to hide the rows stored in the x varaible
    I tried this
    Please Login or Register  to view this content.
    But it doesn't work as the row number should be 1:1 and 7:7 or I have to loop through the x values and do it one by one ..

  25. #25
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Don't do like that,

    Subscript of Range limited to 256 characters, so if you are dealing with large data, it will destroy whole thing.

  26. #26
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot. Is there a faster alternative?

  27. #27
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Simply autofilter.

  28. #28
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    I don't mean using AuotFilter at all. I mean depending on the variable x which has rows numbers that I need to hide.
    Or how can I filter multiple rows based on the variable x?

  29. #29
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    There maybe a several ways to accomplish one thing.
    So, why are you making things too complex meaninglessly by choosing the wrong way?

    Autofilter is absolutely faster.

  30. #30
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    As I told you, I am just playing around using Filter VBA Function with Evaluate .. to learn new stuff
    Thanks a lot for the great information in this topic.

  31. #31
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Please Login or Register  to view this content.
    Do it for yourself for 256 limit.

  32. #32
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot for the nice trick. This is what I am seeking to in this topic in fact.
    I have no specific problem at all. I am just playing with such lines so as to discover the tips and tricks .. I have to thank you in each post for all these useful tricks.

  33. #33
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    If you find any free time. Not now because I exhausted you
    How can I apply multiple filter based on the rows numbers stored in the x variable? Give me simple example to get it well.

  34. #34
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Are you always forget what you got helped or you leave yourself not try to learn?

    https://chandoo.org/forum/threads/gr...-method.28031/

  35. #35
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    This is from 2016 so certainly I forgot about it. Forgive me ..
    And not all the issues I posted I can get all the information from it well. I am trying to learn as possible as I can. But it is natural to forget my tutor.

  36. #36
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    No excuse, everything is there.
    Learn from what you got helped first and not ask same thing again and again.

  37. #37
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    OK my tutor.
    Best Regards

  38. #38
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    I have tried to do that across a row not a column like that
    Please Login or Register  to view this content.
    I have played a round but every time I got an error.

  39. #39
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Filter function with evaluate

    Please Login or Register  to view this content.

  40. #40
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Filter function with evaluate

    Thanks a lot. So we use Transpose when dealing with column range but we don't need it as already we are dealing with a row.
    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Evaluate Function?
    By mpdegn in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2013, 08:21 AM
  2. VBA Evaluate function
    By asheshrocky in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-07-2011, 03:36 AM
  3. Evaluate function in VBA
    By keith101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2010, 06:37 PM
  4. EVALUATE Function
    By Frank H. in forum Excel - New Users/Basics
    Replies: 6
    Last Post: 09-09-2009, 04:02 PM
  5. Evaluate function
    By sachinkatre in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2009, 04:49 PM
  6. Function Evaluate
    By raty in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2008, 05:58 AM
  7. [SOLVED] Please evaluate my new function
    By Caezar in forum Excel General
    Replies: 3
    Last Post: 08-16-2006, 12:25 PM
  8. evaluate a function
    By Ali Baba in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-03-2005, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1