View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
freddy007 freddy007 is offline
external usenet poster
 
Posts: 2
Default macro to insert function without parameters

My goal is to write a macro that inserts this into the active cell:

=stdev( or =stdev()

and then have it act just like if the user had typed the same thing,
that is, be ready to accept a range of cells.

If I type: =stdev() into a cell and hit enter, I get a message that
says "The formula you typed contains an error". If I say ok, then the
message goes away and I get the behavior I want. So what I want to do
is automate that (including the clicking ok part.)

I have tried:
activecell.value = "=stdev()"
activecell.text = "=stdev()"
sendkeys "=stdev("

I get errors with all of those. Putting in "on error resume next"
hasn't helped either, because the error happens before it inserts the
formula.

I know I can write a macro to calculate the StDev of a previously
selected range and put the answer below, and I have done that, but now
this is the behavior I want. It is for students, and I want them to see
the formula and how it works.

Any help would be greatly appreciated.