+ Reply to Thread
Results 1 to 20 of 20

#VALUE error in private function

  1. #1
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    #VALUE error in private function

    Hello,

    I use the code below to count the empty cells and with a certain fill color.
    If I select a few cells the function works, but if i select all the cells i need i get the #VALUE error.
    I think this is because my cells have al kinds of format categories like general, text and number.
    Does anyone know how i can solve this error?

    Tx!

    Please Login or Register  to view this content.

  2. #2
    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: #VALUE error in private function

    How are you calling the function when you get the error?
    Rory

  3. #3
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    Just in a cell formula. =CountCells(range)

  4. #4
    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: #VALUE error in private function

    What range? Are there any error values in the range, or merged cells?

  5. #5
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    A named range. No there are no error values in the range and no merged cells

  6. #6
    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: #VALUE error in private function

    Perhaps you could post a sample workbook to make life easier?

  7. #7
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    ah you were right. There is an error in the named range. Is there a way to ignore errors in the function? It is a very big data sheet and there will always be a few errors.

  8. #8
    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: #VALUE error in private function

    Assuming you want to ignore error cells, you might use:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    Yeah that'll work. I now have a second problem, the cell is only opdated when one of the cells in the named range is changed. I need it to be updated when another macro is called.
    I tried the calculate now option(F9) but that doesn't work. Do you know a sollution to this?

  10. #10
    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: #VALUE error in private function

    The ideal is to stop using colours as data. But if you can't do that, you'll have to make the function volatile by adding:

    Please Login or Register  to view this content.
    after the declaration line.

  11. #11
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    What is the declaration line?

  12. #12
    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: #VALUE error in private function

    The first one:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    That doesn't work either. I don't know why but none of the re-calculate functions work

  14. #14
    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: #VALUE error in private function

    It should work, though you may have to just edit and re-enter one of the formula cells to force the code to be recompiled.

  15. #15
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    Ah yes it works now. Tx!

  16. #16
    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: #VALUE error in private function

    Glad to help. Thanks for the rep.

  17. #17
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    Hello Guys,

    Another problem occured... When there is no error in the range i still get the #VALUE error. After a bit of testing it appears that it is not the cell format that is the problem. I used the function multiple times with different named ranges. When i enter a value in ome cell all the different functions return #VALUE. Do you guys have any idea what can be the reason that triggers the errors?

    Tx!
    Last edited by Afjio12; 04-23-2019 at 07:32 AM.

  18. #18
    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: #VALUE error in private function

    I suggest you post a sample workbook showing the problem.

  19. #19
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: #VALUE error in private function

    Suggestion:

    Please Login or Register  to view this content.
    If applied to a large range, that's going to be pretty brutal on performance.
    Entia non sunt multiplicanda sine necessitate

  20. #20
    Registered User
    Join Date
    02-27-2019
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    70

    Re: #VALUE error in private function

    Unfortunately the same problem occurs with this sollution. Tx anyway!

+ 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. Combine Private Sub and Private Function VBA code
    By thanhthinh1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2018, 06:16 AM
  2. Call Private Function under Private Sub
    By thanhthinh1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-25-2018, 03:23 AM
  3. [SOLVED] Compile Error 'Sub or Function is not define' error on Private Sub Getdata()
    By HafizuddinLowhim in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2014, 11:17 AM
  4. [SOLVED] On Error run Private Sub Workbook_Open() <-- is this possible?
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2014, 03:38 AM
  5. Compile Error: Private Sub Worksheet_Change
    By Matt W in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-02-2011, 01:22 PM
  6. private sub worksheet error
    By excellentexcel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2009, 11:20 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