Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Why recalculation does not start?

I have the following function:

Option Explicit

Static Function abc(a, Optional b As Range)
a = a
If a = 0 Then
Dim m
m = Range("rr")
abc = 0
Else
abc = m(a, 1)
End If
End Function

In my sheet I have:
=abc(0,A1:A3)
=abc(1,A1:A3)
=abc(2,A1:A3)
=abc(3,A1:A3)

When I change a cell in A1:A3, why recalc does not start? I am forced
to use Ctrl-Alt-F9, which I don't like.

What's wrong with my code?

Vicente Soler
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Why recalculation does not start?

Hi,

Try

Application.volatile

as the first line of your UDF

Mike



"vsoler" wrote:

I have the following function:

Option Explicit

Static Function abc(a, Optional b As Range)
a = a
If a = 0 Then
Dim m
m = Range("rr")
abc = 0
Else
abc = m(a, 1)
End If
End Function

In my sheet I have:
=abc(0,A1:A3)
=abc(1,A1:A3)
=abc(2,A1:A3)
=abc(3,A1:A3)

When I change a cell in A1:A3, why recalc does not start? I am forced
to use Ctrl-Alt-F9, which I don't like.

What's wrong with my code?

Vicente Soler

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Why recalculation does not start?

On Sep 22, 9:50*pm, Mike H wrote:
Hi,

Try

Application.volatile

as the first line of your UDF

Mike

"vsoler" wrote:
I have the following function:


Option Explicit


Static Function abc(a, Optional b As Range)
a = a
If a = 0 Then
* Dim m
* m = Range("rr")
* abc = 0
Else
* abc = m(a, 1)
End If
End Function


In my sheet I have:
=abc(0,A1:A3)
=abc(1,A1:A3)
=abc(2,A1:A3)
=abc(3,A1:A3)


When I change a cell in A1:A3, why recalc does not start? I am forced
to use Ctrl-Alt-F9, which I don't like.


What's wrong with my code?


Vicente Soler


Thank you Mike, but can you tell me why it does not recalculate? I'd
like to understand why.

Regards
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Why recalculation does not start?

the function is meaningless

a=a ??

at one line m is assigned a vlaue from a range, but the function returns
zero; at another point m seesm to be an array, but it isn't populsted with
any data and an error results.

declaring variables is a MUST DO so as to prevent typing and syntactual
errors at the minimum

here's my guess at what you want:

Option Explicit
Public Function abc(a As Long, Optional b As Range)
Dim m As Variant
If a = 0 Then
abc = Range("rr").Value
Else
m = b
abc = m(1, a)
End If
End Function








"vsoler" wrote:

On Sep 22, 9:50 pm, Mike H wrote:
Hi,

Try

Application.volatile

as the first line of your UDF

Mike

"vsoler" wrote:
I have the following function:


Option Explicit


Static Function abc(a, Optional b As Range)
a = a
If a = 0 Then
Dim m
m = Range("rr")
abc = 0
Else
abc = m(a, 1)
End If
End Function


In my sheet I have:
=abc(0,A1:A3)
=abc(1,A1:A3)
=abc(2,A1:A3)
=abc(3,A1:A3)


When I change a cell in A1:A3, why recalc does not start? I am forced
to use Ctrl-Alt-F9, which I don't like.


What's wrong with my code?


Vicente Soler


Thank you Mike, but can you tell me why it does not recalculate? I'd
like to understand why.

Regards

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop and start Sheet recalculation jlclyde Excel Discussion (Misc queries) 0 January 29th 08 04:08 PM
start learning Excel/VBA, where to start from? Any online video lectures? cfman Excel Programming 8 September 29th 06 10:40 AM
OT :Start your own online business today !start making dollars [email protected] Excel Discussion (Misc queries) 0 May 6th 06 09:29 PM
Start spreadsheet with WinXP start Gordon Gradwell Excel Worksheet Functions 1 July 13th 05 11:35 AM
Too much recalculation Diane Meade[_2_] Excel Programming 2 May 26th 04 07:19 PM


All times are GMT +1. The time now is 01:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"