Apr 23 2024 11:54 AM - edited Apr 23 2024 01:40 PM
I have this function called funcContentsErrorFree that takes three arguments and returns a Boolean value.
Arguments:
Note: For ease, let's think in terms of values, input, and output.
Function Returns:
Here's the strange thing. This function is located in a module called mRangeValidationFunctions. When I run a test in that module, the function works fine. When I run a test in frmGoalSeekPlus, the Userform crashes.
When I run the function in mRangeValidationFunctions with the same string addresses passed from frmGoalSeekPlus, the function works. So, I thought the location of the function might be an issue. However when I cut/copied the function into frmGoalSeekPlus, it still crashed the form. So, I don't think the location should be an issue. (To further support this thesis, I have two other functions in mRangeValidationFunctions that work fine.)
I'm hoping this is a simple mistake that I'm overlooking. I've included the code and placed comments to make the error section obvious. I've also included the tests in frmGoalSeekPlus and mRangeValidationFunctions so you can see that the function works in the module, but not the form.
All sections are commented for ease of navigation. Use the comment banners and to navigate to the related code. Really hoping to get a second set of eyes on this one.
mRangeValidationFunctions
frmGoalSeekPlus
Note: The goal for this project to make GoalSeek dynamic and give it the power to do some scenario analysis.
Apr 23 2024 06:13 PM
Update:
The source of the error is the Range(refInput).Value assignment lines. See Screenshot.
When these lines are commented out, the code runs error-free but does not perform its designed task.