From: MichaelDavid on
Greetings! This one has me stumped. I am trying to populate a range with a
formula. The code is:

Sub TestSetAC2()
Range("AC2:AC10").Formula = "=SetAC2"
Exit Sub
End Sub

Function SetAC2()
SetAC2 = 5
End Function

First I opened a blank worksheet. When I execute the procedure, I get #Name?
thruout the range. The tool tip just to the left of #Name? says that the
formula contains unrecognized text. Any help will be greatly appreciated.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
From: Joel on
SetAC2 is a function and need the parethesis

Range("AC2:AC10").Formula = "=SetAC2()"

"MichaelDavid" wrote:

> Greetings! This one has me stumped. I am trying to populate a range with a
> formula. The code is:
>
> Sub TestSetAC2()
> Range("AC2:AC10").Formula = "=SetAC2"
> Exit Sub
> End Sub
>
> Function SetAC2()
> SetAC2 = 5
> End Function
>
> First I opened a blank worksheet. When I execute the procedure, I get #Name?
> thruout the range. The tool tip just to the left of #Name? says that the
> formula contains unrecognized text. Any help will be greatly appreciated.
> --
> May you have a most blessed day!
>
> Sincerely,
>
> Michael Fitzpatrick
From: MichaelDavid on
Hi Joel:
I added () like you suggested, and still get #Name? populated
thruout the range. What should I try next?
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"Joel" wrote:

> SetAC2 is a function and need the parethesis
>
> Range("AC2:AC10").Formula = "=SetAC2()"
>
> "MichaelDavid" wrote:
>
> > Greetings! This one has me stumped. I am trying to populate a range with a
> > formula. The code is:
> >
> > Sub TestSetAC2()
> > Range("AC2:AC10").Formula = "=SetAC2"
> > Exit Sub
> > End Sub
> >
> > Function SetAC2()
> > SetAC2 = 5
> > End Function
> >
> > First I opened a blank worksheet. When I execute the procedure, I get #Name?
> > thruout the range. The tool tip just to the left of #Name? says that the
> > formula contains unrecognized text. Any help will be greatly appreciated.
> > --
> > May you have a most blessed day!
> >
> > Sincerely,
> >
> > Michael Fitzpatrick
From: MichaelDavid on
By the way, I tried the example on page 18 of "Excel 2007 VBA Programmer's
Reference" (ISBN 978-0-470-04643-2). The example is the creation of a UDF
(User Defined Function) to convert degrees Centigrade to degrees Fahrenheit.
The code is as follows, and I placed it in a module in my Personal Macro
Notebook:

Function Fahrenheit(Centigrade)
Fahrenheit = Centigrade * 9 / 5 + 32
End Function

Column A of the worksheet has the Centigrade values to be converted, and
Column B is to have the resultant Fahrenheit degrees. When I set B2 on the
worksheet to =Fahrenheit(A2) as per the example in the book, B2 displays as
#Name?. Perhaps there is a setting in my Excel setup which prohibits setting
B2 in this way. I tried this example also with Excel 2003 on another computer
with the same results.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"MichaelDavid" wrote:

> Hi Joel:
> I added () like you suggested, and still get #Name? populated
> thruout the range. What should I try next?
> --
> May you have a most blessed day!
>
> Sincerely,
>
> Michael Fitzpatrick
>
>
> "Joel" wrote:
>
> > SetAC2 is a function and need the parethesis
> >
> > Range("AC2:AC10").Formula = "=SetAC2()"
> >
> > "MichaelDavid" wrote:
> >
> > > Greetings! This one has me stumped. I am trying to populate a range with a
> > > formula. The code is:
> > >
> > > Sub TestSetAC2()
> > > Range("AC2:AC10").Formula = "=SetAC2"
> > > Exit Sub
> > > End Sub
> > >
> > > Function SetAC2()
> > > SetAC2 = 5
> > > End Function
> > >
> > > First I opened a blank worksheet. When I execute the procedure, I get #Name?
> > > thruout the range. The tool tip just to the left of #Name? says that the
> > > formula contains unrecognized text. Any help will be greatly appreciated.
> > > --
> > > May you have a most blessed day!
> > >
> > > Sincerely,
> > >
> > > Michael Fitzpatrick
From: MichaelDavid on
Another possibility: Perhaps, with certain Excel setups, one has to register
a new User Defined Function with Excel.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick


"MichaelDavid" wrote:

> Greetings! This one has me stumped. I am trying to populate a range with a
> formula. The code is:
>
> Sub TestSetAC2()
> Range("AC2:AC10").Formula = "=SetAC2"
> Exit Sub
> End Sub
>
> Function SetAC2()
> SetAC2 = 5
> End Function
>
> First I opened a blank worksheet. When I execute the procedure, I get #Name?
> thruout the range. The tool tip just to the left of #Name? says that the
> formula contains unrecognized text. Any help will be greatly appreciated.
> --
> May you have a most blessed day!
>
> Sincerely,
>
> Michael Fitzpatrick