View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Excel 97 - Application.Iteration is always FALSE?

nonsense..

Could it be that you try to change iteration within the
a VBA function.. ???

Functions CANNOT change the environment when called from
the worksheet!


Sub IterTest()
Application.Iteration = False
IterFunc Range("a1:a20")
Range("b1").Formula = "=IterFunc(a1:a20)"
End Sub

Function IterFunc(rng As Range) As Double
With Application
If TypeOf .Caller Is Range Then
Debug.Print "called from worksheet!"
Else
Debug.Print "called from vba procedure"
End If
.Iteration = True
Debug.Print "INSIDE FUNCTION SET TRUE"; .Iteration
.Iteration = False
Debug.Print "INSIDE FUNCTION SET FALSE"; .Iteration
IterFunc = .WorksheetFunction.Sum(rng)
End With

End Function


Now look at the immediate screen.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Umfriend) wrote:

Dear all,

Still on Excel 97 (but wonbdering about higher versions as well) I
want to query whether Iteration is on or off. It appears that while
running VBA (In a UDF, not sure abotu Subs), Applicaiton.Iteration is
alwaqs False. I can see from the Options dialog that it is actually
on. Printing Applicaiton.Iteration before and after the UDF is called
also returns TRUE.

Is there a way to be able to query that actual status of Iteration?

Function Iter_Status()
If Application.Iteration Then
Iter_Status = "TRUE"
End If
End Function

Kind rgds,
Umf