Update value. Function

  • Follow


Hello,

I created a simple function on VBA as follows:

Function Test() As Integer
  Dim I As Single
  For I = 17 To 24
    Test = (Test + 1) * Range("Examples_1_a_4!B" & I)
  Next I
End Function

On my Excel sheet I have on a cell the following:
=Test()

It works but when I change a value in the range I need to go to the
result cell and click enter to the value be updated.

Why?

Thanks,
Miguel
0
Reply shapper 11/20/2009 1:26:43 PM

Hi Miguel

You have to make you funciton volatile, to do so, add this as first line in 
you sub:

Application.Volatile

Regards,
Per

"shapper" <mdmoura@gmail.com> skrev i meddelelsen 
news:8e30527c-90d4-4475-bd8e-f495208e8eb9@s31g2000yqs.googlegroups.com...
> Hello,
>
> I created a simple function on VBA as follows:
>
> Function Test() As Integer
>  Dim I As Single
>  For I = 17 To 24
>    Test = (Test + 1) * Range("Examples_1_a_4!B" & I)
>  Next I
> End Function
>
> On my Excel sheet I have on a cell the following:
> =Test()
>
> It works but when I change a value in the range I need to go to the
> result cell and click enter to the value be updated.
>
> Why?
>
> Thanks,
> Miguel 

0
Reply Per 11/20/2009 1:34:53 PM

On Nov 20, 1:34=A0pm, "Per Jessen" <per.jes...@mail.dk> wrote:
> Hi Miguel
>
> You have to make you funciton volatile, to do so, add this as first line =
in
> you sub:
>
> Application.Volatile
>
> Regards,
> Per
>
> "shapper" <mdmo...@gmail.com> skrev i meddelelsennews:8e30527c-90d4-4475-=
bd8e-f495208e8eb9@s31g2000yqs.googlegroups.com...
>
> > Hello,
>
> > I created a simple function on VBA as follows:
>
> > Function Test() As Integer
> > =A0Dim I As Single
> > =A0For I =3D 17 To 24
> > =A0 =A0Test =3D (Test + 1) * Range("Examples_1_a_4!B" & I)
> > =A0Next I
> > End Function
>
> > On my Excel sheet I have on a cell the following:
> > =3DTest()
>
> > It works but when I change a value in the range I need to go to the
> > result cell and click enter to the value be updated.
>
> > Why?
>
> > Thanks,
> > Miguel
>
>

Thanks,

It worked just fine.

Thank You,
Miguel
0
Reply shapper 11/20/2009 3:33:56 PM

2 Replies
142 Views

(page loaded in 0.061 seconds)

Similiar Articles:
















7/15/2012 6:07:38 AM


Reply: