I have a workbook with a function that has work just fine for the last year. Basically, it calculates prices of various orders. I have added a module to post the amounts to a database and the formulas all turn to #VALUE. Anybody know what would cause this?
Function Return #VALUE!
-
-
-
Re: Code Causing Function To Crash?
Does this happen only when you run the code from that specific Module that you added in? Did you try running the code as normal without the Module (basically just trying to figure out of it is actually the module is causing the problem).
Can you post the code in that Module?
Ger
-
Re: Code Causing Function To Crash?
It's really weird. Basically, it is an invoice template. Once the data has been imported, the function kicks in and calculates the line items. The old module would create a "Copy & PasteAsValues" workbook that we e-mail to our customer. That has worked fine for a year now. All I really did was add code to post the values to a database. When I step through the code, right in the middle of execution it starts recalculating the function again, than returns #VALUE and then I get a mismatch error. I tried turning calculation off at the beginning of the module, and that succeeded in retaining the values long enough to get them to the database, but once I turn calculation back on, it re-calcs the worksheet and I get the #VALUEs again. Really strange.
-
Re: Code Causing Function To Crash?
Maybe as has been asked by Ger Plante, please can You post up both the codes?
Please be sure to use VBA code tags for Your VBA part of Your post, cheers buddyjiuk
-
Re: Code Causing Function To Crash?
Actually, while waiting for a response, I tried a few things and finally got it to work. All I did was remove the function and place it in another module. Would this make a difference? I wouldn't think so, but I'm learning everyday. It doesn't seem like having the function in the same module as the code would matter, in fact, I do this in other workbooks without a problem. I appreciate everyone's help.
-
-
Re: Code Causing Function To Crash?
Quote#VALUE. Anybody know what would cause this?
Yes, text when number is needed, or vice verca. Cannot complete its calculation, error in code. Variable that is out of scope being passed to the function.
-
Re: Function Return #VALUE!
I think you hit the nail on the head, Dave. In my Application.WorksheetFunction.Vlookup I had designated TRUE when the list wasn't sorted. I changed it to FALSE AND sorted the list, and that seemed to clear it up. Sometimes the simplest things, huh? You look so hard for something so subtle. Thank you again.
-
Re: Function Return #VALUE!
Thanks for posting back with your solution.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!