View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones[_2_] Norman Jones[_2_] is offline
external usenet poster
 
Posts: 421
Default triggering Workbook_SheetCalculate

Hi Steffi,

I removed the Application Volatile instruction
from your UDF.

Changing the values of (say) cells B3 or G3 on
the Jelentés worksheet updates the cell containing
the formula:

=fileexists(Jelentés!$B3&Jelentés!G3)

on the Segéd sheet



---
Regards.
Norman


"Stefi" wrote in message
...
Hi Norman.

I tried to understand your suggestions, but I couldn't apply them to my
case. So I post the code of Workbook_SheetCalculate and the UDF hoping you
can give me some more useful advices.

Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Worksheets("Jelentés").CommandButton1.Enabled = _
Names("megvane").RefersToRange.Item(1, 1) And _
Names("megvane").RefersToRange.Item(1, 2) And _
Names("megvane").RefersToRange.Item(2, 1) And _
Names("megvane").RefersToRange.Item(2, 2)
Worksheets("Jelentés").CommandButton3.Enabled = _
Names("megvane").RefersToRange.Item(2, 3)
Worksheets("Jelentés").CommandButton2.Enabled = _
Names("megvane").RefersToRange.Item(3, 1) And _
Names("megvane").RefersToRange.Item(3, 2)
Worksheets("Jelentés").CommandButton4.Enabled = _
Names("megvane").RefersToRange.Item(3, 3)
End Sub

The UDF:
Public Function FileExists(fname, Optional most As Date) As Boolean
Application.Volatile
FileExists = False
On Error Resume Next
FileExists = IIf(Dir(fname) < "", True, False)
End Function

Range "megvane" is in another sheet named "segéd", range("G3:I5"), the
first
item (G3) contains
=fileexists(Jelentés!$B3&Jelentés!G3)

which is filled to the right and down throghout the range.
Jelentés!$B3 contains folder name,
Jelentés!G3 contains file name
of files existence of which is to be checked. The do not change, therefore
UDF is not recalculated. I'd like that the UDF be recalculated when
pressing
F9, to re-check the existence of the files.

How can I do that without Volatile

Regards,
Stefi