By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

The following custom formula hangs excel

P: 1
Expand|Select|Wrap|Line Numbers
  1. Public Function Test(rng As Range) As Double
  2.     Set oRng = Application.ActiveSheet.Range("A1", "A3")
  3.     oRng.Formula = "=C3+C5"
  4.     Test = 0
  5. End Function
I don't know if the problem is that it's not possible to modify the "Formula" property of a cell from a custom formula.
Is there any solution?
Thanks for your help!
Apr 30 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Expand|Select|Wrap|Line Numbers
  1. Public Function Test(rng As Range) As Double
  2.     Set oRng = Application.ActiveSheet.Range("A1", "A3")
  3.     oRng.Formula = "=C3+C5"
  4.     Test = 0
  5. End Function
I don't know if the problem is that it's not possible to modify the "Formula" property of a cell from a custom formula.
Is there any solution?
Thanks for your help!
Not sure exactly what the problem is here, but there are a couple of things which stand out...
  • Where is oRng defined? How does it relate to the parameter rng that was passed to the function?
  • Have you tried commenting out lines of code (starting with all of them commented) to work out exactly where it's hanging?
  • I'm not that familiar with Excel's VBA, so bear with me - is it possible to set .Formula for a range like this, as opposed to an individual cell?
  • Is it possible you have set up some sort of circular reference? For example, is there a formula in cell C3 or C5 which refers to the Test() function? In that case, your function might be causing a calculation which calls your function, which causes a calculation which calls your function, which causes a calculation which calls your function, which causes a calculation which calls your function, ... I think you get the idea - see why that would get hung up?
Apr 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.