+ Reply to Thread
Results 1 to 38 of 38

Stubborn Evaluate 2015 Error

  1. #1
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Stubborn Evaluate 2015 Error

    Hi Everybody,

    This question should be reproducible with a random set of data including blank cells. What could be causing Error 2015 and how do I fix it?

    As a learning exercise, I am trying to create general purpose syntax which evaluates a statement to find the location of blank cells through a backward (Do) loop, if none are found then the Do is exited. For example:
    Please Login or Register  to view this content.
    I have tried Application.WorksheetFunction.Match, Application.Match, .Find and found a few other less popular methods, however, I like the evaluate method above for its general power. Unfortunately it throws Error 2015 and don't know why (well and truly under the character limit). Hopefully this is a clearly worded question, if not, please do not hesitate to ask for further clarification.
    Attached Images Attached Images
    Last edited by Maze123; 10-21-2020 at 05:58 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Stubborn Evaluate 2015 Error

    Hi and welcome to the forum.

    Please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.


    To upload a file click the Go Advanced button at the foot of your post, look underneath the post area for the Manage Attachments section and take it from there.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: Stubborn Evaluate 2015 Error

    Please Login or Register  to view this content.
    Doesn't make sense...

  4. #4
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Hi Richard,

    Thank you - looks like a great resource!

    This is the cut-down, anonymised version as I have removed the code which cuts+paste row corresponding to position of matching empty cell. The idea of the "match and move action" is captured in the attached snippet. Hope this helps?


    Regards,

  5. #5
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Doesn't make sense...
    From my readings I understand that a cell can be Null or truly "empty" and gathered that the sub couldn't find an empty cell. So, I repurposed some code using Match-Index but I am not convinced of its efficacy myself. Interestingly, it seems to find an empty cell because it does not assign h=0, instead showing the error.

  6. #6
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Actually, @Jindon and @Richard Buttrey, is it better if I move this problem to the commercial service, given it seems trickier than usual?

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

    Re: Stubborn Evaluate 2015 Error

    No, you don't need to.

    1) Assuming Range is the Range name for A1:A10
    Please Login or Register  to view this content.
    It returns Error when A1:A10 are all filled.
    But, if it is a variable, that line always returns Error.

    2) The conditions for both If and ElseIf clause are the same.
    Please Login or Register  to view this content.
    ElseIf will never let the variable h to 0.

    So, even if 1) returns correct results, it will do nothing...

    If you upload a workbook and show us before/after, it will help.

  8. #8
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Thanks, @jindon. Constructing a workbook excluding confidential work info. In the meantime:

    (1) Altered variable type to Range (which should name the range).

    (2)
    (a) Hmmm, so both statements are perfectly alike which means the elseif condition is not satisfied and would let h=0?
    (b) Retained IsEmpty form only but still not finding the blanks.

    Also, if a match is found it would skip the If conditions and return something?

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

    Re: Stubborn Evaluate 2015 Error

    [] , shortcut notation of Evaluate method doesn't accept Variables.
    So, if a Range is a String Variable like "A1:A10", it should be like
    Please Login or Register  to view this content.
    If Range is a Range object
    Please Login or Register  to view this content.
    If, I said earlier, Range is the name of the Named Range in the worksheet, your code should return Error or Numeric value.

    All I want to say is that We can not even guess, what you are trying to do from the code you posted...

  10. #10
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Please see attached workbook to demonstrate my objective
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    [] , shortcut notation of Evaluate method doesn't accept Variables.
    So, if a Range is a String Variable like "A1:A10", it should be like
    Please Login or Register  to view this content.
    If Range is a Range object
    Please Login or Register  to view this content.
    If, I said earlier, Range is the name of the Named Range in the worksheet, your code should return Error or Numeric value.

    All I want to say is that We can not even guess, what you are trying to do from the code you posted...
    This is really good to know. I have compiled a workbook demonstrating my objective, @jindon, thank you for persevering.

    What is the best reference book for VBA Excel in your opinion? … I'd rather not cause unnecessary annoyance.

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

    Re: Stubborn Evaluate 2015 Error

    You are welcome.
    You may find good material here, New to Excel Programming and looking for learning materials

    As for the code, I still don't understand what you are trying to do.

    What do you expect to happen when
    1) Blank cell is found
    2) All are filled (No blank within the range)
    ?
    Last edited by jindon; 10-22-2020 at 01:18 AM.

  13. #13
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    You are welcome.
    You may find good material here, New to Excel Programming and looking for learning materials

    As for the code, I still don't understand what you are trying to do.

    What do you expect to happen when
    1) Blank cell is found
    2) All are filled (No blank within the range)
    ?
    Thank you, I will buy this book and begin a proper study of the language.

    (1) Using the location of the cell - row number specifically - to move the corresponding row to the bottom of the range; then delete original position which shifts the rows up (hence looping backwards).
    (2) Attached snippet shows 2 blank cells in the range

    Hope this helps?
    Attached Images Attached Images

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

    Re: Stubborn Evaluate 2015 Error

    Do you just want to delete the blank cell(s)?
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Do you just want to delete the blank cell(s)?
    Please Login or Register  to view this content.
    No, the row containing the blank cell is important and, further, because the Do loop is moving up (range scope diminishing) it would stop the moment no blanks remained. Not meaning to sound cryptic but the column is sorted after rows with blanks are at the bottom.

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

    Re: Stubborn Evaluate 2015 Error

    Then can you just upload a workbook with Before the macro and After the macro sheets?

  17. #17
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Then can you just upload a workbook with Before the macro and After the macro sheets?
    Wish I could but the datasets are huge and highly sensitive, what I have provided is reduced to isolate the matching issue. Essentially, I just need the match function to identify the existance of blanks - they exist - because the rest of the code surrounding it works.

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

    Re: Stubborn Evaluate 2015 Error

    Since I'm not clear, this is to give you the Row ref/(Address) of blank cell(s) from bottom to the top.
    Please Login or Register  to view this content.
    I need to go out now, so my next response will be late.

  19. #19
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Maybe this snippet will help
    Attached Images Attached Images

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

    Re: Stubborn Evaluate 2015 Error

    Not really sure if this is how you wanted.
    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Not really sure if this is how you wanted.
    Please Login or Register  to view this content.
    This is getting closer, @Jindon, but due to dataset size I was incorporating a Do While loop to exit when blanks are no longer found. After playing with your construct, I am unsure how to rearrange as such. I'll keep trying.

  22. #22
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    So, in summary, the following 4 formula's achieve the desired result:
    (1)
    Please Login or Register  to view this content.
    (2)
    Please Login or Register  to view this content.
    (3)
    Please Login or Register  to view this content.
    (4) ***non-VBA compatible
    Please Login or Register  to view this content.
    Disregarding (4), why is it so technically complicated to EVALUATE (1)-(3)? It would simplify our approach a lot. For example, I don't understand why writing
    Please Login or Register  to view this content.
    is syntactically incorrect?

  23. #23
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Stubborn Evaluate 2015 Error

    They are not syntactically incorrect.
    Rory

  24. #24
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19
    Quote Originally Posted by rorya View Post
    They are not syntactically incorrect.
    Hmm, yet output is still Error 2015 and blanks are clearly contained inside the specified range. Theoretically, variable h should = some row number corresponding to the 1st blank. Don't get it, @rorya.

  25. #25
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Stubborn Evaluate 2015 Error

    Post a simple workbook with the actual code, including specific ranges, that shows it not working.

  26. #26
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by rorya View Post
    Post a simple workbook with the actual code, including specific ranges, that shows it not working.
    Please see attached, @rorya, the code is now completely stripped down to the evaluate function yielding the same Error 2015.
    Attached Files Attached Files

  27. #27
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Stubborn Evaluate 2015 Error

    Your formula is wrong. For example:

    Please Login or Register  to view this content.
    works just fine.

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

    Re: Stubborn Evaluate 2015 Error

    Don't know how many rows/columns you have.
    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by rorya View Post
    Your formula is wrong. For example:

    Please Login or Register  to view this content.
    works just fine.
    Thank you, @rorya. Unclear as to why encasing the string compiles correctly in VBA but it works. Interestingly, after verifying the output, nesting the function inside a loop produces an Error 2042. Do you know why this is the case or a subject for another question?

  30. #30
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Don't know how many rows/columns you have.
    Please Login or Register  to view this content.
    Wow, this looks cool but is beyond my comprehension. I have tried the following:

    Please Login or Register  to view this content.
    Which errors. Evaluate computes correctly without error outside the Loop though. Is this structure possible, @Jindon?

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

    Re: Stubborn Evaluate 2015 Error

    What does that Do Loop suppose to do?

    h is always the same value Error or 1st blank row.

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

    Re: Stubborn Evaluate 2015 Error

    This is only my guess, but it is.... wrong way...

    Please Login or Register  to view this content.
    That is exactly the same as
    Please Login or Register  to view this content.
    Last edited by jindon; 10-22-2020 at 10:23 PM.

  33. #33
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    This is only my guess, but it is.... wrong way...

    Please Login or Register  to view this content.
    That is exactly the same as
    Please Login or Register  to view this content.
    Modifying to
    Please Login or Register  to view this content.
    Should work but Evaluate still produces Error 2042 now that a loop is incorporated. Would you mind explaining the logic of
    Please Login or Register  to view this content.
    pls, @Jindon?
    Last edited by Maze123; 10-22-2020 at 11:54 PM.

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

    Re: Stubborn Evaluate 2015 Error

    Please Login or Register  to view this content.
    Again I don't understand the use of Evaluate method in this case...

  35. #35
    Registered User
    Join Date
    10-21-2020
    Location
    Brisbane, Australia
    MS-Off Ver
    2019
    Posts
    19

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    Again I don't understand the use of Evaluate method in this case...
    I am not advanced enough to use your previous solutions regrettably, so Evaluate is the most powerful general solution I can understand and adapt to other questions.

    Damn … I can't get rid of this Error 2042 - is your h variable still erroring, @Jindon?

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

    Re: Stubborn Evaluate 2015 Error

    Evaluate method is indeed powerful, but not in this case.
    It slows down the process.
    Attached Files Attached Files

  37. #37
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Stubborn Evaluate 2015 Error

    Error 2042 is the equivalent of a #N/A error, which means there aren't any blank cells in the range you are looking at.

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

    Re: Stubborn Evaluate 2015 Error

    Quote Originally Posted by Maze123 View Post
    Damn … I can't get rid of this Error 2042 - is your h variable still erroring, @Jindon?
    Missed this one...

    You can not get rid of Error 2042 because of your formula structure.
    That's why
    Please Login or Register  to view this content.
    that Evaluate should return 1 when A & i is blank, otherwise Error 2042,
    Why not just
    Please Login or Register  to view this content.
    So no calculation time is taken.

+ 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. Stubborn VLOOKUP error, all formatting is correct - help!
    By stevensimon10482 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2017, 01:15 AM
  2. [SOLVED] I want to pop up a MsgBox if if user enters date like 2015.04.30 instead of 30.04.2015.
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-09-2015, 10:00 AM
  3. Workaround for Error 2015 when function too long using Application.Evaluate?
    By jprealini in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2014, 04:06 PM
  4. Error 2015 and #VALUE!
    By vop2311 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 01:46 AM
  5. [SOLVED] Error 2015 with Application.Evaluate
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2006, 11:10 AM
  6. Error 2015
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2006, 03:40 PM
  7. [SOLVED] N/A # and error 2015
    By ina in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-27-2006, 05:55 AM

Tags for this Thread

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