Hi,
Whilst I appreciate your suggestions and am grateful for the time you are spending on my problem we do seem to be suffering a bit from mission creep. Your solution would mean an extensive rewrite of the real life worksheet using VBA and I am not sure my VBA skills are up to that yet! :-(
There is a lot more to the real life workbook than the example put up on the post. The example has been cut down in an attempt to comply with Forum rules. The full workbook has a total of 35 sheets with many interdependences and sanitising it would be both very time consuming and run a high risk of missing sensitive data. I am sure it would break the rules for simplicity and brevity.
In addition there are a number of other entries with different intervals, descriptions, and amounts for both receipts and expenditure and I was hoping to extend the scope of the UDF to include these once I had got this one working.
I do now understand that a function, whether built in or a UDF, cannot change a cell other than the cell from which it is called, which I did not when I embarked on this task. I cannot, however, understand why a UDF cannot find a value on another worksheet on which to base a calculation to obtain its return value? To me it seems an unreasonable restriction, after all my public UDF "PrevSheet(cell ref)" does just that. I have tried running PrevSheet() from within VBA, which I thought was legal, but I get a compile error “Sub or Variable not defined”.
The formula in Cell C15 on the May worksheet does what I want the UDF to do but I cannot get it to cope with two receipts in one month. Is there not a way to do what that formula does using VBA? I have tried “Record Macro” then running the formula but all I get in the macro is "Range("C16").Select"
If I cannot do this with a UDF then I will have to give it up as a bad job as I am not I a position to start the whole thing from scratch. I seems it’s going to have to go on the “too hard heap” unfortunately.
Maybe after studying John’s book I will get some other ideas or acquire the skills to follow up on your suggestions.
Thank you for your kind efforts, they are much appreciated.
Regards,
Tegglet
Bookmarks